Completed
Push — master ( b70884...5fde98 )
by Fabien
55:11
created
Tests/Functional/AbstractFunctionalTestCase.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@
 block discarded – undo
9 9
  */
10 10
 abstract class AbstractFunctionalTestCase extends FunctionalTestCase
11 11
 {
12
-    protected $testExtensionsToLoad = array('typo3conf/ext/vidi');
12
+	protected $testExtensionsToLoad = array('typo3conf/ext/vidi');
13 13
 
14
-    protected $coreExtensionsToLoad = array('extbase', 'fluid', 'scheduler');
14
+	protected $coreExtensionsToLoad = array('extbase', 'fluid', 'scheduler');
15 15
 
16
-    public function setUp(): void
17
-    {
18
-        parent::setUp();
19
-    }
16
+	public function setUp(): void
17
+	{
18
+		parent::setUp();
19
+	}
20 20
 }
Please login to merge, or discard this patch.
Tests/Functional/Module/ModuleLoaderTest.php 2 patches
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -24,101 +24,101 @@
 block discarded – undo
24 24
  */
25 25
 class ModuleLoaderTest extends AbstractFunctionalTestCase
26 26
 {
27
-    /**
28
-     * @var ModuleLoader
29
-     */
30
-    private $fixture;
31
-
32
-    /**
33
-     * @var string
34
-     */
35
-    private $dataType = 'tx_foo';
36
-
37
-    /**
38
-     * @var string
39
-     */
40
-    private $moduleCode = 'user_VidiTxFooM1';
41
-
42
-
43
-    public function setUp()
44
-    {
45
-        parent::setUp();
46
-        $this->fixture = new ModuleLoader($this->dataType);
47
-        $this->fixture->register();
48
-    }
49
-
50
-    public function tearDown()
51
-    {
52
-        unset($this->fixture);
53
-    }
54
-
55
-    /**
56
-     * @test
57
-     * @dataProvider attributeValueProvider
58
-     */
59
-    public function attributeCanBeSet($attribute, $value)
60
-    {
61
-        $setter = 'set' . ucfirst($attribute);
62
-        $this->fixture->$setter($value);
63
-        $this->assertAttributeEquals($value, $attribute, $this->fixture);
64
-    }
65
-
66
-    /**
67
-     * Provider
68
-     */
69
-    public function attributeValueProvider()
70
-    {
71
-        return array(
72
-            array('icon', 'bar'),
73
-            array('moduleLanguageFile', 'bar'),
74
-        );
75
-    }
76
-
77
-    /**
78
-     * @test
79
-     * @dataProvider attributeProvider
80
-     */
81
-    public function testAttribute($attribute, $defaultValue)
82
-    {
83
-        $this->assertAttributeEquals($defaultValue, $attribute, $this->fixture);
84
-    }
85
-
86
-    /**
87
-     * Provider
88
-     */
89
-    public function attributeProvider()
90
-    {
91
-        return array(
92
-            array('dataType', $this->dataType),
93
-            array('moduleKey', 'm1'),
94
-            array('icon', 'EXT:vidi/ext_icon.gif')
95
-        );
96
-    }
97
-
98
-    /**
99
-     * @test
100
-     */
101
-    public function getModuleConfigurationReturnsArrayWithSomeKeys()
102
-    {
103
-        $moduleLoader = new ModuleLoader($this->dataType);
104
-        $moduleLoader->register();
105
-        $GLOBALS['_GET']['M'] = $this->moduleCode;
106
-
107
-        $moduleConfiguration = $moduleLoader->getModuleConfiguration();
108
-        $keys = array('dataType', 'additionalJavaScriptFiles', 'additionalStyleSheetFiles');
109
-        foreach ($keys as $key) {
110
-            $this->assertArrayHasKey($key, $moduleConfiguration);
111
-        }
112
-    }
113
-
114
-    /**
115
-     * @test
116
-     */
117
-    public function getModuleConfigurationWithParameterDataTypeReturnsDataType()
118
-    {
119
-        $moduleLoader = new ModuleLoader($this->dataType);
120
-        $moduleLoader->register();
121
-        $GLOBALS['_GET']['M'] = $this->moduleCode;
122
-        $this->assertEquals($this->dataType, $moduleLoader->getModuleConfiguration('dataType'));
123
-    }
27
+	/**
28
+	 * @var ModuleLoader
29
+	 */
30
+	private $fixture;
31
+
32
+	/**
33
+	 * @var string
34
+	 */
35
+	private $dataType = 'tx_foo';
36
+
37
+	/**
38
+	 * @var string
39
+	 */
40
+	private $moduleCode = 'user_VidiTxFooM1';
41
+
42
+
43
+	public function setUp()
44
+	{
45
+		parent::setUp();
46
+		$this->fixture = new ModuleLoader($this->dataType);
47
+		$this->fixture->register();
48
+	}
49
+
50
+	public function tearDown()
51
+	{
52
+		unset($this->fixture);
53
+	}
54
+
55
+	/**
56
+	 * @test
57
+	 * @dataProvider attributeValueProvider
58
+	 */
59
+	public function attributeCanBeSet($attribute, $value)
60
+	{
61
+		$setter = 'set' . ucfirst($attribute);
62
+		$this->fixture->$setter($value);
63
+		$this->assertAttributeEquals($value, $attribute, $this->fixture);
64
+	}
65
+
66
+	/**
67
+	 * Provider
68
+	 */
69
+	public function attributeValueProvider()
70
+	{
71
+		return array(
72
+			array('icon', 'bar'),
73
+			array('moduleLanguageFile', 'bar'),
74
+		);
75
+	}
76
+
77
+	/**
78
+	 * @test
79
+	 * @dataProvider attributeProvider
80
+	 */
81
+	public function testAttribute($attribute, $defaultValue)
82
+	{
83
+		$this->assertAttributeEquals($defaultValue, $attribute, $this->fixture);
84
+	}
85
+
86
+	/**
87
+	 * Provider
88
+	 */
89
+	public function attributeProvider()
90
+	{
91
+		return array(
92
+			array('dataType', $this->dataType),
93
+			array('moduleKey', 'm1'),
94
+			array('icon', 'EXT:vidi/ext_icon.gif')
95
+		);
96
+	}
97
+
98
+	/**
99
+	 * @test
100
+	 */
101
+	public function getModuleConfigurationReturnsArrayWithSomeKeys()
102
+	{
103
+		$moduleLoader = new ModuleLoader($this->dataType);
104
+		$moduleLoader->register();
105
+		$GLOBALS['_GET']['M'] = $this->moduleCode;
106
+
107
+		$moduleConfiguration = $moduleLoader->getModuleConfiguration();
108
+		$keys = array('dataType', 'additionalJavaScriptFiles', 'additionalStyleSheetFiles');
109
+		foreach ($keys as $key) {
110
+			$this->assertArrayHasKey($key, $moduleConfiguration);
111
+		}
112
+	}
113
+
114
+	/**
115
+	 * @test
116
+	 */
117
+	public function getModuleConfigurationWithParameterDataTypeReturnsDataType()
118
+	{
119
+		$moduleLoader = new ModuleLoader($this->dataType);
120
+		$moduleLoader->register();
121
+		$GLOBALS['_GET']['M'] = $this->moduleCode;
122
+		$this->assertEquals($this->dataType, $moduleLoader->getModuleConfiguration('dataType'));
123
+	}
124 124
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 use Fab\Vidi\Module\ModuleLoader;
18 18
 use Fab\Vidi\Tests\Functional\AbstractFunctionalTestCase;
19 19
 
20
-require_once dirname(dirname(__FILE__)) . '/AbstractFunctionalTestCase.php';
20
+require_once dirname(dirname(__FILE__)).'/AbstractFunctionalTestCase.php';
21 21
 
22 22
 /**
23 23
  * Test case for class \Fab\Vidi\Module\ModuleLoader.
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      */
59 59
     public function attributeCanBeSet($attribute, $value)
60 60
     {
61
-        $setter = 'set' . ucfirst($attribute);
61
+        $setter = 'set'.ucfirst($attribute);
62 62
         $this->fixture->$setter($value);
63 63
         $this->assertAttributeEquals($value, $attribute, $this->fixture);
64 64
     }
Please login to merge, or discard this patch.
Tests/Feature/bootstrap/FeatureContext.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -9,45 +9,45 @@
 block discarded – undo
9 9
  */
10 10
 class FeatureContext extends MinkContext
11 11
 {
12
-    /**
13
-     * Initializes context.
14
-     * Every scenario gets it's own context object.
15
-     *
16
-     * @param array $parameters context parameters (set them up through behat.yml)
17
-     */
18
-    public function __construct(array $parameters)
19
-    {
20
-        // Initialize your context here
21
-    }
12
+	/**
13
+	 * Initializes context.
14
+	 * Every scenario gets it's own context object.
15
+	 *
16
+	 * @param array $parameters context parameters (set them up through behat.yml)
17
+	 */
18
+	public function __construct(array $parameters)
19
+	{
20
+		// Initialize your context here
21
+	}
22 22
 
23
-    /**
24
-     * @Given /^I wait "([^"]*)" seconds$/
25
-     */
26
-    public function iWaitSeconds($seconds)
27
-    {
28
-        sleep($seconds);
29
-    }
23
+	/**
24
+	 * @Given /^I wait "([^"]*)" seconds$/
25
+	 */
26
+	public function iWaitSeconds($seconds)
27
+	{
28
+		sleep($seconds);
29
+	}
30 30
 
31
-    /**
32
-     * @Given /^I am on the main page$/
33
-     */
34
-    public function iAmOnTheMainPage()
35
-    {
36
-        return array(
37
-            new Behat\Behat\Context\Step\Given(sprintf('I am on "%s"', 'mod.php?M=user_MediaM1')),
38
-        );
39
-    }
31
+	/**
32
+	 * @Given /^I am on the main page$/
33
+	 */
34
+	public function iAmOnTheMainPage()
35
+	{
36
+		return array(
37
+			new Behat\Behat\Context\Step\Given(sprintf('I am on "%s"', 'mod.php?M=user_MediaM1')),
38
+		);
39
+	}
40 40
 
41
-    /**
42
-     * @Given /^I am logged in as "([^"]*)" with password "([^"]*)"$/
43
-     */
44
-    public function iAmLoggedInAsWithPassword($username, $password)
45
-    {
46
-        $this->loginUrl = 'http://media.fab/';
47
-        return array(
48
-            new Behat\Behat\Context\Step\Given(sprintf('I am on "%s"', $this->loginUrl)),
49
-            new When(sprintf('I fill in "Password" with "%s"', $password)),
50
-            new When('I press "Identification"'),
51
-        );
52
-    }
41
+	/**
42
+	 * @Given /^I am logged in as "([^"]*)" with password "([^"]*)"$/
43
+	 */
44
+	public function iAmLoggedInAsWithPassword($username, $password)
45
+	{
46
+		$this->loginUrl = 'http://media.fab/';
47
+		return array(
48
+			new Behat\Behat\Context\Step\Given(sprintf('I am on "%s"', $this->loginUrl)),
49
+			new When(sprintf('I fill in "Password" with "%s"', $password)),
50
+			new When('I press "Identification"'),
51
+		);
52
+	}
53 53
 }
Please login to merge, or discard this patch.
Tests/Unit/Module/ModulePreferencesTest.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@
 block discarded – undo
10 10
  */
11 11
 class ModulePreferencesTest extends UnitTestCase
12 12
 {
13
-    /**
14
-     * @test
15
-     */
16
-    public function instantiateMe()
17
-    {
18
-        $fixture = new ModulePreferences();
19
-        $this->assertInstanceOf('Fab\Vidi\Module\ModulePreferences', $fixture);
20
-    }
13
+	/**
14
+	 * @test
15
+	 */
16
+	public function instantiateMe()
17
+	{
18
+		$fixture = new ModulePreferences();
19
+		$this->assertInstanceOf('Fab\Vidi\Module\ModulePreferences', $fixture);
20
+	}
21 21
 }
Please login to merge, or discard this patch.
Tests/Unit/Formatter/DateTest.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -10,29 +10,29 @@
 block discarded – undo
10 10
  */
11 11
 class DateTest extends UnitTestCase
12 12
 {
13
-    /**
14
-     * @var Date
15
-     */
16
-    private $subject;
13
+	/**
14
+	 * @var Date
15
+	 */
16
+	private $subject;
17 17
 
18
-    public function setUp()
19
-    {
20
-        date_default_timezone_set('GMT');
21
-        $this->subject = new Date();
22
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] = 'd.m.Y';
23
-    }
18
+	public function setUp()
19
+	{
20
+		date_default_timezone_set('GMT');
21
+		$this->subject = new Date();
22
+		$GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] = 'd.m.Y';
23
+	}
24 24
 
25
-    public function tearDown()
26
-    {
27
-        unset($this->subject);
28
-    }
25
+	public function tearDown()
26
+	{
27
+		unset($this->subject);
28
+	}
29 29
 
30
-    /**
31
-     * @test
32
-     */
33
-    public function canFormatDate()
34
-    {
35
-        $foo = $this->subject->format('1351880525');
36
-        $this->assertEquals('02.11.2012', $foo);
37
-    }
30
+	/**
31
+	 * @test
32
+	 */
33
+	public function canFormatDate()
34
+	{
35
+		$foo = $this->subject->format('1351880525');
36
+		$this->assertEquals('02.11.2012', $foo);
37
+	}
38 38
 }
Please login to merge, or discard this patch.
Tests/Unit/Formatter/DatetimeTest.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -23,30 +23,30 @@
 block discarded – undo
23 23
  */
24 24
 class DatetimeTest extends UnitTestCase
25 25
 {
26
-    /**
27
-     * @var Date
28
-     */
29
-    private $subject;
26
+	/**
27
+	 * @var Date
28
+	 */
29
+	private $subject;
30 30
 
31
-    public function setUp()
32
-    {
33
-        date_default_timezone_set('GMT');
34
-        $this->subject = new Datetime();
35
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] = 'd.m.Y';
36
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] = 'H:i';
37
-    }
31
+	public function setUp()
32
+	{
33
+		date_default_timezone_set('GMT');
34
+		$this->subject = new Datetime();
35
+		$GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] = 'd.m.Y';
36
+		$GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] = 'H:i';
37
+	}
38 38
 
39
-    public function tearDown()
40
-    {
41
-        unset($this->subject);
42
-    }
39
+	public function tearDown()
40
+	{
41
+		unset($this->subject);
42
+	}
43 43
 
44
-    /**
45
-     * @test
46
-     */
47
-    public function canFormatDatetime()
48
-    {
49
-        $foo = $this->subject->format('1351880525');
50
-        $this->assertEquals('02.11.2012 18:22', $foo);
51
-    }
44
+	/**
45
+	 * @test
46
+	 */
47
+	public function canFormatDatetime()
48
+	{
49
+		$foo = $this->subject->format('1351880525');
50
+		$this->assertEquals('02.11.2012 18:22', $foo);
51
+	}
52 52
 }
Please login to merge, or discard this patch.
Tests/Unit/Tca/TableServiceTest.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -33,36 +33,36 @@
 block discarded – undo
33 33
  */
34 34
 class TableServiceTest extends AbstractServiceTest
35 35
 {
36
-    /**
37
-     * @var TableService
38
-     */
39
-    private $fixture;
36
+	/**
37
+	 * @var TableService
38
+	 */
39
+	private $fixture;
40 40
 
41
-    public function setUp()
42
-    {
43
-        parent::setUp();
44
-        $this->fixture = new TableService('tx_foo', Tca::TYPE_TABLE);
45
-    }
41
+	public function setUp()
42
+	{
43
+		parent::setUp();
44
+		$this->fixture = new TableService('tx_foo', Tca::TYPE_TABLE);
45
+	}
46 46
 
47
-    public function tearDown()
48
-    {
49
-        unset($this->fixture);
50
-    }
47
+	public function tearDown()
48
+	{
49
+		unset($this->fixture);
50
+	}
51 51
 
52
-    /**
53
-     * @test
54
-     */
55
-    public function getLabelReturnNameAsValue()
56
-    {
57
-        $this->assertEquals('username', $this->fixture->getLabelField());
58
-    }
52
+	/**
53
+	 * @test
54
+	 */
55
+	public function getLabelReturnNameAsValue()
56
+	{
57
+		$this->assertEquals('username', $this->fixture->getLabelField());
58
+	}
59 59
 
60
-    /**
61
-     * @test
62
-     */
63
-    public function getSearchableFieldsIsNotEmptyByDefaultForTableSysFile()
64
-    {
65
-        $actual = $this->fixture->getSearchFields();
66
-        $this->assertNotEmpty($actual);
67
-    }
60
+	/**
61
+	 * @test
62
+	 */
63
+	public function getSearchableFieldsIsNotEmptyByDefaultForTableSysFile()
64
+	{
65
+		$actual = $this->fixture->getSearchFields();
66
+		$this->assertNotEmpty($actual);
67
+	}
68 68
 }
Please login to merge, or discard this patch.
Tests/Unit/Tca/GridServiceTest.php 1 patch
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -22,186 +22,186 @@
 block discarded – undo
22 22
  */
23 23
 class GridServiceTest extends AbstractServiceTest
24 24
 {
25
-    /**
26
-     * @var GridService
27
-     */
28
-    private $fixture;
29
-
30
-    public function setUp()
31
-    {
32
-        parent::setUp();
33
-        $this->fixture = $this->getMock('Fab\Vidi\Tca\GridService', array('getModulePreferences'), array('tx_foo', Tca::TYPE_GRID));
34
-
35
-        // Configure the ModulePreferences
36
-        $mockModulePreferences = $this->getMock('Fab\Vidi\Module\ModulePreferences');
37
-        $mockModulePreferences->expects($this->once())->method('get')->will($this->returnValue(array()));
38
-        $this->fixture->expects($this->once())->method('getModulePreferences')->will($this->returnValue($mockModulePreferences));
39
-
40
-        $GLOBALS['BE_USER'] = $this->getMock('TYPO3\CMS\Core\Authentication\BackendUserAuthentication', [], [], '', false);
41
-        $GLOBALS['BE_USER']->expects($this->any())->method('isAdmin')->will($this->returnValue(true));
42
-    }
43
-
44
-    public function tearDown()
45
-    {
46
-        unset($this->fixture);
47
-    }
48
-
49
-    /**
50
-     * test
51
-     */
52
-    #public function getLabelReturnNameAsValue() {
53
-    #	$GLOBALS['LANG'] = $this->getMock('TYPO3\CMS\Core\Localization\LanguageService', [], [], '', false);
54
-    #	$GLOBALS['LANG']->expects($this->once())->method('sL')->will($this->returnValue('Name'));
55
-    #
56
-    #	$this->assertEquals('Name', $this->fixture->getLabel('name'));
57
-    #}
58
-
59
-    /**
60
-     * @test
61
-     */
62
-    public function getFieldNamesReturnsNotEmpty()
63
-    {
64
-        $actual = $this->fixture->getFieldNames();
65
-
66
-        $this->assertTrue(is_array($actual));
67
-        $this->assertNotEmpty($actual);
68
-        $this->assertTrue(in_array('username', $actual));
69
-    }
70
-
71
-    /**
72
-     * @test
73
-     */
74
-    public function getColumnsReturnsAnNotEmptyArray()
75
-    {
76
-        $actual = $this->fixture->getFields();
77
-        $this->assertTrue(is_array($actual));
78
-        $this->assertNotEmpty($actual);
79
-    }
80
-
81
-    /**
82
-     * @test
83
-     */
84
-    public function getFieldsReturnsGreaterThanNumberOfColumns()
85
-    {
86
-        $actual = $this->fixture->getFields();
87
-        $this->assertGreaterThanOrEqual(count($actual), count($GLOBALS['TCA']['tx_foo']['columns']));
88
-    }
89
-
90
-    /**
91
-     * @test
92
-     */
93
-    public function additionalFieldsAreHiddenByDefault()
94
-    {
95
-        $actual = $this->fixture->getFields();
96
-        $this->assertFalse($actual['birthday']['visible']);
97
-    }
98
-
99
-    /**
100
-     * @test
101
-     */
102
-    public function additionalFieldBirthDayIsFormattedAsDate()
103
-    {
104
-        $actual = $this->fixture->getFields();
105
-        $this->assertEquals('Fab\Vidi\Formatter\Date', $actual['birthday']['format']);
106
-    }
107
-
108
-    /**
109
-     * @test
110
-     */
111
-    public function additionalFieldStartTimeIsFormattedAsDateTime()
112
-    {
113
-        $actual = $this->fixture->getFields();
114
-        $this->assertEquals('Fab\Vidi\Formatter\Datetime', $actual['starttime']['format']);
115
-    }
116
-
117
-    /**
118
-     * @test
119
-     */
120
-    public function getConfigurationForColumnUsername()
121
-    {
122
-        $actual = $this->fixture->getField('username');
123
-        $this->assertTrue(is_array($actual));
124
-        $this->assertTrue(count($actual) > 0);
125
-    }
126
-
127
-    /**
128
-     * @test
129
-     */
130
-    public function additionalColumnFirstNameShouldNotBeVisible()
131
-    {
132
-        $actual = $this->fixture->isVisible('first_name');
133
-        $this->assertFalse($actual);
134
-    }
135
-
136
-    /**
137
-     * @test
138
-     */
139
-    public function columnUsernameShouldBeSortableByDefault()
140
-    {
141
-        $this->assertTrue($this->fixture->isSortable('username'));
142
-    }
143
-
144
-    /**
145
-     * @test
146
-     */
147
-    public function columnNumberShouldBeNotSortableByDefault()
148
-    {
149
-        $this->assertFalse($this->fixture->isSortable('usergroup'));
150
-    }
151
-
152
-    /**
153
-     * @test
154
-     */
155
-    public function getExcludedFieldsReturnsArray()
156
-    {
157
-        $result = $this->fixture->getExcludedFields();
158
-        $this->assertInternalType('array', $result);
159
-    }
160
-
161
-    /**
162
-     * @test
163
-     */
164
-    public function getFieldsRemoveFieldMiddleNameFromResultSet()
165
-    {
166
-        $result = $this->fixture->getFields();
167
-        $this->assertArrayNotHasKey('middle_name', $result);
168
-    }
169
-
170
-    /**
171
-     * @test
172
-     */
173
-    public function columnUsernameShouldBeVisibleByDefault()
174
-    {
175
-        $this->assertTrue($this->fixture->isVisible('username'));
176
-    }
177
-
178
-    /**
179
-     * @test
180
-     */
181
-    public function getConfigurationOfNotExistingColumnReturnsAnException()
182
-    {
183
-        $expected = [];
184
-        $this->assertEquals($expected, $this->fixture->getRenderers('bar'));
185
-    }
186
-
187
-    /**
188
-     * @test
189
-     */
190
-    public function getFieldsAndCheckWhetherItsPositionReturnsTheCorrectFieldName()
191
-    {
192
-        $fields = array_keys($this->fixture->getFields());
193
-        for ($index = 0; $index < count($fields); $index++) {
194
-            $actual = $this->fixture->getFieldNameByPosition($index);
195
-            $this->assertSame($fields[$index], $actual);
196
-        }
197
-    }
198
-
199
-    /**
200
-     * @test
201
-     */
202
-    public function canGetLabelKeyCodeForFakeFieldUserGroups()
203
-    {
204
-        $fieldName = 'usergroup';
205
-        $this->assertEquals($GLOBALS['TCA']['tx_foo']['grid']['columns'][$fieldName]['label'], $this->fixture->getLabelKey($fieldName));
206
-    }
25
+	/**
26
+	 * @var GridService
27
+	 */
28
+	private $fixture;
29
+
30
+	public function setUp()
31
+	{
32
+		parent::setUp();
33
+		$this->fixture = $this->getMock('Fab\Vidi\Tca\GridService', array('getModulePreferences'), array('tx_foo', Tca::TYPE_GRID));
34
+
35
+		// Configure the ModulePreferences
36
+		$mockModulePreferences = $this->getMock('Fab\Vidi\Module\ModulePreferences');
37
+		$mockModulePreferences->expects($this->once())->method('get')->will($this->returnValue(array()));
38
+		$this->fixture->expects($this->once())->method('getModulePreferences')->will($this->returnValue($mockModulePreferences));
39
+
40
+		$GLOBALS['BE_USER'] = $this->getMock('TYPO3\CMS\Core\Authentication\BackendUserAuthentication', [], [], '', false);
41
+		$GLOBALS['BE_USER']->expects($this->any())->method('isAdmin')->will($this->returnValue(true));
42
+	}
43
+
44
+	public function tearDown()
45
+	{
46
+		unset($this->fixture);
47
+	}
48
+
49
+	/**
50
+	 * test
51
+	 */
52
+	#public function getLabelReturnNameAsValue() {
53
+	#	$GLOBALS['LANG'] = $this->getMock('TYPO3\CMS\Core\Localization\LanguageService', [], [], '', false);
54
+	#	$GLOBALS['LANG']->expects($this->once())->method('sL')->will($this->returnValue('Name'));
55
+	#
56
+	#	$this->assertEquals('Name', $this->fixture->getLabel('name'));
57
+	#}
58
+
59
+	/**
60
+	 * @test
61
+	 */
62
+	public function getFieldNamesReturnsNotEmpty()
63
+	{
64
+		$actual = $this->fixture->getFieldNames();
65
+
66
+		$this->assertTrue(is_array($actual));
67
+		$this->assertNotEmpty($actual);
68
+		$this->assertTrue(in_array('username', $actual));
69
+	}
70
+
71
+	/**
72
+	 * @test
73
+	 */
74
+	public function getColumnsReturnsAnNotEmptyArray()
75
+	{
76
+		$actual = $this->fixture->getFields();
77
+		$this->assertTrue(is_array($actual));
78
+		$this->assertNotEmpty($actual);
79
+	}
80
+
81
+	/**
82
+	 * @test
83
+	 */
84
+	public function getFieldsReturnsGreaterThanNumberOfColumns()
85
+	{
86
+		$actual = $this->fixture->getFields();
87
+		$this->assertGreaterThanOrEqual(count($actual), count($GLOBALS['TCA']['tx_foo']['columns']));
88
+	}
89
+
90
+	/**
91
+	 * @test
92
+	 */
93
+	public function additionalFieldsAreHiddenByDefault()
94
+	{
95
+		$actual = $this->fixture->getFields();
96
+		$this->assertFalse($actual['birthday']['visible']);
97
+	}
98
+
99
+	/**
100
+	 * @test
101
+	 */
102
+	public function additionalFieldBirthDayIsFormattedAsDate()
103
+	{
104
+		$actual = $this->fixture->getFields();
105
+		$this->assertEquals('Fab\Vidi\Formatter\Date', $actual['birthday']['format']);
106
+	}
107
+
108
+	/**
109
+	 * @test
110
+	 */
111
+	public function additionalFieldStartTimeIsFormattedAsDateTime()
112
+	{
113
+		$actual = $this->fixture->getFields();
114
+		$this->assertEquals('Fab\Vidi\Formatter\Datetime', $actual['starttime']['format']);
115
+	}
116
+
117
+	/**
118
+	 * @test
119
+	 */
120
+	public function getConfigurationForColumnUsername()
121
+	{
122
+		$actual = $this->fixture->getField('username');
123
+		$this->assertTrue(is_array($actual));
124
+		$this->assertTrue(count($actual) > 0);
125
+	}
126
+
127
+	/**
128
+	 * @test
129
+	 */
130
+	public function additionalColumnFirstNameShouldNotBeVisible()
131
+	{
132
+		$actual = $this->fixture->isVisible('first_name');
133
+		$this->assertFalse($actual);
134
+	}
135
+
136
+	/**
137
+	 * @test
138
+	 */
139
+	public function columnUsernameShouldBeSortableByDefault()
140
+	{
141
+		$this->assertTrue($this->fixture->isSortable('username'));
142
+	}
143
+
144
+	/**
145
+	 * @test
146
+	 */
147
+	public function columnNumberShouldBeNotSortableByDefault()
148
+	{
149
+		$this->assertFalse($this->fixture->isSortable('usergroup'));
150
+	}
151
+
152
+	/**
153
+	 * @test
154
+	 */
155
+	public function getExcludedFieldsReturnsArray()
156
+	{
157
+		$result = $this->fixture->getExcludedFields();
158
+		$this->assertInternalType('array', $result);
159
+	}
160
+
161
+	/**
162
+	 * @test
163
+	 */
164
+	public function getFieldsRemoveFieldMiddleNameFromResultSet()
165
+	{
166
+		$result = $this->fixture->getFields();
167
+		$this->assertArrayNotHasKey('middle_name', $result);
168
+	}
169
+
170
+	/**
171
+	 * @test
172
+	 */
173
+	public function columnUsernameShouldBeVisibleByDefault()
174
+	{
175
+		$this->assertTrue($this->fixture->isVisible('username'));
176
+	}
177
+
178
+	/**
179
+	 * @test
180
+	 */
181
+	public function getConfigurationOfNotExistingColumnReturnsAnException()
182
+	{
183
+		$expected = [];
184
+		$this->assertEquals($expected, $this->fixture->getRenderers('bar'));
185
+	}
186
+
187
+	/**
188
+	 * @test
189
+	 */
190
+	public function getFieldsAndCheckWhetherItsPositionReturnsTheCorrectFieldName()
191
+	{
192
+		$fields = array_keys($this->fixture->getFields());
193
+		for ($index = 0; $index < count($fields); $index++) {
194
+			$actual = $this->fixture->getFieldNameByPosition($index);
195
+			$this->assertSame($fields[$index], $actual);
196
+		}
197
+	}
198
+
199
+	/**
200
+	 * @test
201
+	 */
202
+	public function canGetLabelKeyCodeForFakeFieldUserGroups()
203
+	{
204
+		$fieldName = 'usergroup';
205
+		$this->assertEquals($GLOBALS['TCA']['tx_foo']['grid']['columns'][$fieldName]['label'], $this->fixture->getLabelKey($fieldName));
206
+	}
207 207
 }
Please login to merge, or discard this patch.
Tests/Unit/Tca/AbstractServiceTest.php 1 patch
Indentation   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -10,158 +10,158 @@  discard block
 block discarded – undo
10 10
  */
11 11
 abstract class AbstractServiceTest extends UnitTestCase
12 12
 {
13
-    /**
14
-     * @var GridService
15
-     */
16
-    private $fixture;
13
+	/**
14
+	 * @var GridService
15
+	 */
16
+	private $fixture;
17 17
 
18
-    public function setUp()
19
-    {
20
-        parent::setUp();
18
+	public function setUp()
19
+	{
20
+		parent::setUp();
21 21
 
22
-        $GLOBALS['TCA']['tx_foo'] = array(
23
-            'ctrl' => array(
24
-                'label' => 'username',
25
-                'default_sortby' => 'ORDER BY username',
26
-                'tstamp' => 'tstamp',
27
-                'crdate' => 'crdate',
28
-                'cruser_id' => 'cruser_id',
29
-                'title' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:tx_foo',
30
-                'delete' => 'deleted',
31
-                'enablecolumns' => array(
32
-                    'disabled' => 'disable',
33
-                    'starttime' => 'starttime',
34
-                    'endtime' => 'endtime'
35
-                ),
36
-                'typeicon_classes' => array(
37
-                    'default' => 'status-user-frontend'
38
-                ),
39
-                'searchFields' => 'username,name,first_name,last_name'
40
-            ),
41
-            'columns' => array(
42
-                'username' => array(
43
-                    'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:username',
44
-                    'config' => array(
45
-                        'type' => 'input',
46
-                        'size' => '20',
47
-                        'max' => '255',
48
-                        'eval' => 'nospace,lower,uniqueInPid,required'
49
-                    ),
50
-                ),
51
-                'password' => array(
52
-                    'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:password',
53
-                    'config' => array(
54
-                        'type' => 'input',
55
-                        'size' => '10',
56
-                        'max' => '40',
57
-                        'eval' => 'nospace,required,password'
58
-                    ),
59
-                ),
60
-                'usergroup' => array(
61
-                    'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:usergroup',
62
-                    'config' => array(
63
-                        'type' => 'select',
64
-                        'renderType' => 'selectMultipleSideBySide',
65
-                        'foreign_table' => 'fe_groups',
66
-                        'foreign_table_where' => 'ORDER BY fe_groups.title',
67
-                        'size' => '6',
68
-                        'minitems' => '1',
69
-                        'maxitems' => '50'
70
-                    ),
71
-                ),
72
-                'name' => array(
73
-                    'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:name',
74
-                    'config' => array(
75
-                        'type' => 'input',
76
-                        'size' => '40',
77
-                        'eval' => 'trim',
78
-                        'max' => '80'
79
-                    ),
80
-                ),
81
-                'first_name' => array(
82
-                    'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:first_name',
83
-                    'config' => array(
84
-                        'type' => 'input',
85
-                        'size' => '25',
86
-                        'eval' => 'trim',
87
-                        'max' => '50'
88
-                    ),
89
-                ),
90
-                'last_name' => array(
91
-                    'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:last_name',
92
-                    'config' => array(
93
-                        'type' => 'input',
94
-                        'size' => '25',
95
-                        'eval' => 'trim',
96
-                        'max' => '50'
97
-                    ),
98
-                ),
99
-                'middle_name' => array(
100
-                    'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:middle_name',
101
-                    'config' => array(
102
-                        'type' => 'input',
103
-                        'size' => '25',
104
-                        'eval' => 'trim',
105
-                        'max' => '50'
106
-                    ),
107
-                ),
108
-                'alternative_name' => array(
109
-                    'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:alternative_name',
110
-                    'config' => array(
111
-                        'type' => 'input',
112
-                        'size' => '25',
113
-                        'eval' => 'trim',
114
-                        'max' => '50'
115
-                    ),
116
-                ),
117
-                'birthday' => array(
118
-                    'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:birthday',
119
-                    'config' => array(
120
-                        'type' => 'input',
121
-                        'size' => '25',
122
-                        'eval' => 'date',
123
-                        'max' => '50'
124
-                    ),
125
-                ),
126
-                'starttime' => array(
127
-                    'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:starttime',
128
-                    'config' => array(
129
-                        'type' => 'input',
130
-                        'size' => '13',
131
-                        'max' => '20',
132
-                        'eval' => 'datetime',
133
-                        'default' => '0'
134
-                    ),
135
-                ),
136
-            ),
137
-            'grid' => array(
138
-                'excluded_fields' => 'middle_name, alternative_name',
139
-                'columns' => array(
140
-                    'username' => array(
141
-                        'visible' => true,
142
-                        'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:username',
143
-                        'editable' => true,
144
-                    ),
145
-                    'name' => array(
146
-                        'visible' => true,
147
-                        'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:name',
148
-                        'editable' => true,
149
-                    ),
150
-                    'usergroup' => array(
151
-                        'visible' => true,
152
-                        'renderers' => array(
153
-                            'Fab\Vidi\Grid\RelationEditRenderer',
154
-                            'Fab\Vidi\Grid\RelationRenderer',
155
-                        ),
156
-                        'editable' => true,
157
-                        'sortable' => false,
158
-                        'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:usergroup',
159
-                    ),
160
-                ),
161
-            ),
162
-        );
22
+		$GLOBALS['TCA']['tx_foo'] = array(
23
+			'ctrl' => array(
24
+				'label' => 'username',
25
+				'default_sortby' => 'ORDER BY username',
26
+				'tstamp' => 'tstamp',
27
+				'crdate' => 'crdate',
28
+				'cruser_id' => 'cruser_id',
29
+				'title' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:tx_foo',
30
+				'delete' => 'deleted',
31
+				'enablecolumns' => array(
32
+					'disabled' => 'disable',
33
+					'starttime' => 'starttime',
34
+					'endtime' => 'endtime'
35
+				),
36
+				'typeicon_classes' => array(
37
+					'default' => 'status-user-frontend'
38
+				),
39
+				'searchFields' => 'username,name,first_name,last_name'
40
+			),
41
+			'columns' => array(
42
+				'username' => array(
43
+					'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:username',
44
+					'config' => array(
45
+						'type' => 'input',
46
+						'size' => '20',
47
+						'max' => '255',
48
+						'eval' => 'nospace,lower,uniqueInPid,required'
49
+					),
50
+				),
51
+				'password' => array(
52
+					'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:password',
53
+					'config' => array(
54
+						'type' => 'input',
55
+						'size' => '10',
56
+						'max' => '40',
57
+						'eval' => 'nospace,required,password'
58
+					),
59
+				),
60
+				'usergroup' => array(
61
+					'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:usergroup',
62
+					'config' => array(
63
+						'type' => 'select',
64
+						'renderType' => 'selectMultipleSideBySide',
65
+						'foreign_table' => 'fe_groups',
66
+						'foreign_table_where' => 'ORDER BY fe_groups.title',
67
+						'size' => '6',
68
+						'minitems' => '1',
69
+						'maxitems' => '50'
70
+					),
71
+				),
72
+				'name' => array(
73
+					'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:name',
74
+					'config' => array(
75
+						'type' => 'input',
76
+						'size' => '40',
77
+						'eval' => 'trim',
78
+						'max' => '80'
79
+					),
80
+				),
81
+				'first_name' => array(
82
+					'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:first_name',
83
+					'config' => array(
84
+						'type' => 'input',
85
+						'size' => '25',
86
+						'eval' => 'trim',
87
+						'max' => '50'
88
+					),
89
+				),
90
+				'last_name' => array(
91
+					'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:last_name',
92
+					'config' => array(
93
+						'type' => 'input',
94
+						'size' => '25',
95
+						'eval' => 'trim',
96
+						'max' => '50'
97
+					),
98
+				),
99
+				'middle_name' => array(
100
+					'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:middle_name',
101
+					'config' => array(
102
+						'type' => 'input',
103
+						'size' => '25',
104
+						'eval' => 'trim',
105
+						'max' => '50'
106
+					),
107
+				),
108
+				'alternative_name' => array(
109
+					'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:alternative_name',
110
+					'config' => array(
111
+						'type' => 'input',
112
+						'size' => '25',
113
+						'eval' => 'trim',
114
+						'max' => '50'
115
+					),
116
+				),
117
+				'birthday' => array(
118
+					'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:birthday',
119
+					'config' => array(
120
+						'type' => 'input',
121
+						'size' => '25',
122
+						'eval' => 'date',
123
+						'max' => '50'
124
+					),
125
+				),
126
+				'starttime' => array(
127
+					'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:starttime',
128
+					'config' => array(
129
+						'type' => 'input',
130
+						'size' => '13',
131
+						'max' => '20',
132
+						'eval' => 'datetime',
133
+						'default' => '0'
134
+					),
135
+				),
136
+			),
137
+			'grid' => array(
138
+				'excluded_fields' => 'middle_name, alternative_name',
139
+				'columns' => array(
140
+					'username' => array(
141
+						'visible' => true,
142
+						'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:username',
143
+						'editable' => true,
144
+					),
145
+					'name' => array(
146
+						'visible' => true,
147
+						'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:name',
148
+						'editable' => true,
149
+					),
150
+					'usergroup' => array(
151
+						'visible' => true,
152
+						'renderers' => array(
153
+							'Fab\Vidi\Grid\RelationEditRenderer',
154
+							'Fab\Vidi\Grid\RelationRenderer',
155
+						),
156
+						'editable' => true,
157
+						'sortable' => false,
158
+						'label' => 'LLL:EXT:foo/Resources/Private/Language/tx_foo.xlf:usergroup',
159
+					),
160
+				),
161
+			),
162
+		);
163 163
 
164
-        /*
164
+		/*
165 165
         #################
166 166
         # opposite many
167 167
         # one-to-many
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
         );
247 247
 
248 248
         */
249
-    }
249
+	}
250 250
 
251
-    public function tearDown()
252
-    {
253
-        unset($this->fixture, $GLOBALS['TCA']);
254
-    }
251
+	public function tearDown()
252
+	{
253
+		unset($this->fixture, $GLOBALS['TCA']);
254
+	}
255 255
 }
Please login to merge, or discard this patch.