Completed
Push — master ( a24186...f6f1d1 )
by
unknown
08:07
created

FieldTitleMapperTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A mapData() 0 9 1
A testMap() 0 13 1
1
<?php
2
/**
3
 * validate mapping of names to singular
4
 */
5
6
namespace Graviton\GeneratorBundle\Tests\Generator\ResourceGenerator;
7
8
use \Graviton\GeneratorBundle\Generator\ResourceGenerator\FieldTitleMapper;
9
10
/**
11
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
12
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
13
 * @link     http://swisscom.ch
14
 */
15
class FieldTitleMapperTest extends \PHPUnit_Framework_TestCase
16
{
17
    /**
18
     * @dataProvider mapData
19
     *
20
     * @param string $name     field name form of string
21
     * @param string $expected expected form of string
22
     *
23
     * @return void
24
     */
25
    public function testMap($name, $expected)
26
    {
27
        $sut = new FieldTitleMapper;
28
29
        $field = [
30
            'fieldName' => $name
31
        ];
32
        $expected = [
33
            'fieldName' => $name,
34
            'title' => $expected
35
        ];
36
        $this->assertEquals($expected, $sut->map($field));
37
    }
38
39
    /**
40
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use string[][].

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
41
     */
42
    public function mapData()
43
    {
44
        return [
45
            ['names', 'Names'],
46
            ['busesAreNice', 'Buses are nice'],
47
            ['buses.are.cool', 'Buses are cool'],
48
            ['bus.0.name', 'Bus array name']
49
        ];
50
    }
51
}
52