[!!!][TASK] Extract testing framework for TYPO3
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Tests / Unit / Domain / Model / ExtensionTest.php
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Extension test
19 */
20 class ExtensionTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitTestCase
21 {
22 /**
23 * Data provider for getCategoryIndexFromStringOrNumberReturnsIndex
24 *
25 * @return array
26 */
27 public function getCategoryIndexFromStringOrNumberReturnsIndexDataProvider()
28 {
29 return [
30 'empty string' => [
31 '',
32 4
33 ],
34 'existing category string' => [
35 'plugin',
36 3
37 ],
38 'not existing category string' => [
39 'foo',
40 4
41 ],
42 'string number 3' => [
43 '3',
44 3
45 ],
46 'integer 3' => [
47 3,
48 3
49 ],
50 'string number not in range -1' => [
51 '-1',
52 4
53 ],
54 'integer not in range -1' => [
55 -1,
56 4
57 ],
58 'string number not in range 11' => [
59 '11',
60 4
61 ],
62 'integer not in range 11' => [
63 11,
64 4
65 ],
66 'object' => [
67 new \stdClass(),
68 4
69 ],
70 'array' => [
71 [],
72 4
73 ],
74 ];
75 }
76
77 /**
78 * @test
79 * @dataProvider getCategoryIndexFromStringOrNumberReturnsIndexDataProvider
80 * @param string|int $input Given input
81 * @param int $expected Expected result
82 * @return void
83 */
84 public function getCategoryIndexFromStringOrNumberReturnsIndex($input, $expected)
85 {
86 $extension = new \TYPO3\CMS\Extensionmanager\Domain\Model\Extension;
87 $this->assertEquals($expected, $extension->getCategoryIndexFromStringOrNumber($input));
88 }
89 }