Completed
Push — master ( 4b4c57...035a27 )
by Rafael
03:03
created

CallableNamingStrategyTest::testTransformName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 9.4285
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
/**
4
 * LICENSE: This file is subject to the terms and conditions defined in
5
 * file 'LICENSE', which is part of this source code package.
6
 *
7
 * @copyright 2016 Copyright(c) - All rights reserved.
8
 */
9
10
namespace Rafrsr\LibArray2Object\Tests\Naming;
11
12
use Rafrsr\LibArray2Object\Naming\CallableNamingStrategy;
13
14
class CallableNamingStrategyTest extends \PHPUnit_Framework_TestCase
15
{
16
    public function testTransformName()
17
    {
18
        $strategy = new CallableNamingStrategy(
19
            function ($name) {
20
                return strtoupper($name);
21
            }
22
        );
23
        static::assertEquals('TEST', $strategy->transformName('test'));
24
25
        $strategy = new CallableNamingStrategy('strtolower');
26
        static::assertEquals('test', $strategy->transformName('TEST'));
27
28
        $strategy = new CallableNamingStrategy([$this, 'transform']);
29
        static::assertEquals('Test', $strategy->transformName('test'));
30
    }
31
32
    public function transform($name)
33
    {
34
        return ucfirst($name);
35
    }
36
}
37