1<?php
2
3/**
4 * This file is part of the Phalcon Framework.
5 *
6 * (c) Phalcon Team <team@phalcon.io>
7 *
8 * For the full copyright and license information, please view the LICENSE.txt
9 * file that was distributed with this source code.
10 */
11
12declare(strict_types=1);
13
14namespace Phalcon\Test\Unit\Text;
15
16use Phalcon\Text;
17use UnitTester;
18
19class StartsWithCest
20{
21    /**
22     * Tests Phalcon\Text :: startsWith()
23     *
24     * @author Phalcon Team <team@phalcon.io>
25     * @since  2018-11-13
26     */
27    public function textStartsWith(UnitTester $I)
28    {
29        $I->wantToTest('Text - startsWith()');
30
31        $I->assertTrue(
32            Text::startsWith('Hello', 'H')
33        );
34
35        $I->assertTrue(
36            Text::startsWith('Hello', 'He')
37        );
38
39        $I->assertTrue(
40            Text::startsWith('Hello', 'Hello')
41        );
42    }
43
44    /**
45     * Tests Phalcon\Text :: startsWith() - empty strings
46     *
47     * @author Phalcon Team <team@phalcon.io>
48     * @since  2018-11-13
49     */
50    public function textStartsWithEmpty(UnitTester $I)
51    {
52        $I->wantToTest('Text - startsWith() - empty strings');
53
54        $I->assertFalse(
55            Text::startsWith('', '')
56        );
57    }
58
59    /**
60     * Tests Phalcon\Text :: startsWith() - finding an empty string
61     *
62     * @author Phalcon Team <team@phalcon.io>
63     * @since  2018-11-13
64     */
65    public function textStartsWithEmptySearchString(UnitTester $I)
66    {
67        $I->wantToTest('Text - startsWith() - search empty string');
68
69        $I->assertFalse(
70            Text::startsWith('', 'hello')
71        );
72    }
73
74
75    /**
76     * Tests Phalcon\Text :: startsWith() - case insensitive flag
77     *
78     * @author Phalcon Team <team@phalcon.io>
79     * @since  2018-11-13
80     */
81    public function textStartsWithCaseInsensitive(UnitTester $I)
82    {
83        $I->wantToTest('Text - startsWith() - case insensitive flag');
84
85        $I->assertTrue(
86            Text::startsWith('Hello', 'h')
87        );
88
89        $I->assertTrue(
90            Text::startsWith('Hello', 'he')
91        );
92
93        $I->assertTrue(
94            Text::startsWith('Hello', 'hello')
95        );
96    }
97
98    /**
99     * Tests Phalcon\Text :: startsWith() - case sensitive flag
100     *
101     * @author Phalcon Team <team@phalcon.io>
102     * @since  2018-11-13
103     */
104    public function textStartsWithCaseSensitive(UnitTester $I)
105    {
106        $I->wantToTest('Text - startsWith() - case sensitive flag');
107
108        $I->assertTrue(
109            Text::startsWith('Hello', 'hello', true)
110        );
111
112        $I->assertFalse(
113            Text::startsWith('Hello', 'hello', false)
114        );
115
116        $I->assertFalse(
117            Text::startsWith('Hello', 'h', false)
118        );
119    }
120}
121