StrTest.php
56 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Illuminate\Tests; |
| 4 | |
| 5 | use PHPUnit\Framework\TestCase; |
| 6 | use Illuminate\Support\Str; |
| 7 | |
| 8 | class StrTest extends TestCase |
| 9 | { |
| 10 | public function testPluralizer() |
| 11 | { |
| 12 | $this->assertEquals('houses', Str::plural('house')); |
| 13 | |
| 14 | $this->assertEquals('bison', Str::plural('bison')); |
| 15 | |
| 16 | $this->assertEquals('people', Str::plural('people')); |
| 17 | |
| 18 | $this->assertEquals('feet', Str::plural('foot')); |
| 19 | |
| 20 | $this->assertEquals('foot', Str::singular('feet')); |
| 21 | } |
| 22 | |
| 23 | public function testStart() |
| 24 | { |
| 25 | $this->assertEquals('what house', Str::start('house', 'what ')); |
| 26 | } |
| 27 | |
| 28 | public function testCache() |
| 29 | { |
| 30 | $this->assertEquals('my_house', Str::snake('my house')); |
| 31 | $this->assertEquals('my_house', Str::snake('my house')); |
| 32 | |
| 33 | $this->assertEquals('MyHouse', Str::studly('my house')); |
| 34 | $this->assertEquals('MyHouse', Str::studly('my house')); |
| 35 | |
| 36 | $this->assertEquals('myHouse', Str::camel('my house')); |
| 37 | $this->assertEquals('myHouse', Str::camel('my house')); |
| 38 | } |
| 39 | |
| 40 | public function testLength() |
| 41 | { |
| 42 | $this->assertEquals(8, Str::length('my house')); |
| 43 | $this->assertEquals(8, Str::length('my house', 'UTF-8')); |
| 44 | } |
| 45 | |
| 46 | public function testLimit() |
| 47 | { |
| 48 | $this->assertEquals('my house', Str::limit('my house')); |
| 49 | } |
| 50 | |
| 51 | public function testIs() |
| 52 | { |
| 53 | $this->assertFalse(Str::is([], 'pattern')); |
| 54 | } |
| 55 | } |
| 56 |