Completed
Branch master (36b376)
by Randy
03:14
created

VariantTest::testWithCamelSnakeCase()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Dgame\Variants\Test;
4
5
use Dgame\Variants\Variants;
6
use PHPUnit\Framework\TestCase;
7
8
final class VariantTest extends TestCase
9
{
10
    public function testWithPattern()
11
    {
12
        $value    = '016945236589';
13
        $patterns = [
14
            '/(\d{4})(\d+)/' => ['$1/$2', '$1-$2']
15
        ];
16
17
        $this->assertEquals(['0169/45236589', '0169-45236589'], Variants::ofArguments($value)->withPattern($patterns));
18
    }
19
20
    public function testWithUpperLowerCaseFirst()
21
    {
22
        $this->assertEquals(['foo', 'Foo', 'bar', 'Bar'], Variants::ofArray(['foo', 'bar'])->withUpperLowerCaseFirst());
23
    }
24
25
    public function testWithUpperLowerCase()
26
    {
27
        $this->assertEquals(['foo', 'FOO', 'bar', 'BAR'], Variants::ofArray(['foo', 'bar'])->withUpperLowerCase());
28
        $this->assertEquals(['foo', 'FOO', 'bar', 'BAR'], Variants::ofArray(['fOo', 'bAr'])->withUpperLowerCase());
29
    }
30
31
    public function testWithCamelSnakeCase()
32
    {
33
        $this->assertEquals(
34
            ['callAMethod', 'CallAMethod', 'call_a_method'],
35
            Variants::ofArguments('call a method')->withCamelSnakeCase()
36
        );
37
    }
38
39
    public function testAssembled()
40
    {
41
        $this->assertEquals(
42
            ['callAMethod', 'CallAMethod', 'call_a_method', 'call-a-method'],
43
            Variants::ofArguments('call a method')->assembled()
44
        );
45
    }
46
}