1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: lenovo |
5
|
|
|
* Date: 6/15/2018 |
6
|
|
|
* Time: 11:20 AM |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace TimSDK\Tests\Support; |
10
|
|
|
|
11
|
|
|
use TimSDK\Support\Str; |
12
|
|
|
use TimSDK\Tests\TestCase; |
13
|
|
|
|
14
|
|
|
class StrTest extends TestCase |
15
|
|
|
{ |
16
|
|
|
public function testStartsWith() |
17
|
|
|
{ |
18
|
|
|
$this->assertTrue(Str::startsWith('Hello World', ['foo', 'Hello'])); |
19
|
|
|
$this->assertTrue(Str::startsWith('Hello World', 'Hello')); |
20
|
|
|
$this->assertFalse(Str::startsWith('Hello World', 'foo')); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function testEndsWith() |
24
|
|
|
{ |
25
|
|
|
$this->assertTrue(Str::endsWith('Hello World', ['Worlds', 'World'])); |
26
|
|
|
$this->assertTrue(Str::endsWith('Hello World', 'World')); |
27
|
|
|
$this->assertFalse(Str::endsWith('Hello World', 'Worlds')); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function testUpper() |
31
|
|
|
{ |
32
|
|
|
$this->assertSame('HELLOWORLD', Str::upper('HelloWorld')); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function testLower() |
36
|
|
|
{ |
37
|
|
|
$this->assertSame('helloworld', Str::lower('HelloWorld')); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testSnake() |
41
|
|
|
{ |
42
|
|
|
$this->assertSame('foo_bar', Str::snake('fooBar')); |
43
|
|
|
$this->assertSame('foo_bar', Str::snake('FooBar')); |
44
|
|
|
$this->assertSame('foo-bar', Str::snake('fooBar', '-')); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function testCamel() |
48
|
|
|
{ |
49
|
|
|
$this->assertSame('laravelPHPFramework', Str::camel('Laravel_p_h_p_framework')); |
50
|
|
|
$this->assertSame('laravelPhpFramework', Str::camel('Laravel_php_framework')); |
51
|
|
|
$this->assertSame('laravelPhPFramework', Str::camel('Laravel-phP-framework')); |
52
|
|
|
$this->assertSame('laravelPhpFramework', Str::camel('Laravel -_- php -_- framework ')); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function testStudly() |
56
|
|
|
{ |
57
|
|
|
$this->assertSame('LaravelPHPFramework', Str::studly('laravel_p_h_p_framework')); |
58
|
|
|
$this->assertSame('LaravelPhpFramework', Str::studly('laravel_php_framework')); |
59
|
|
|
$this->assertSame('LaravelPhPFramework', Str::studly('laravel-phP-framework')); |
60
|
|
|
$this->assertSame('LaravelPhpFramework', Str::studly('laravel -_- php -_- framework ')); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|