c0611db3d87283a2993fb1f02b1fe7685b57639f
[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 * Copyright notice
6 *
7 * (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Extension test
29 */
30 class ExtensionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
31
32 /**
33 * Data provider for getCategoryIndexFromStringOrNumberReturnsIndex
34 *
35 * @return array
36 */
37 public function getCategoryIndexFromStringOrNumberReturnsIndexDataProvider() {
38 return array(
39 'empty string' => array(
40 '',
41 4
42 ),
43 'existing category string' => array(
44 'plugin',
45 3
46 ),
47 'not existing category string' => array(
48 'foo',
49 4
50 ),
51 'string number 3' => array(
52 '3',
53 3
54 ),
55 'integer 3' => array(
56 3,
57 3
58 ),
59 'string number not in range -1' => array(
60 '-1',
61 4
62 ),
63 'integer not in range -1' => array(
64 -1,
65 4
66 ),
67 'string number not in range 11' => array(
68 '11',
69 4
70 ),
71 'integer not in range 11' => array(
72 11,
73 4
74 ),
75 'object' => array(
76 new \stdClass(),
77 4
78 ),
79 'array' => array(
80 array(),
81 4
82 ),
83 );
84 }
85
86 /**
87 * @test
88 * @dataProvider getCategoryIndexFromStringOrNumberReturnsIndexDataProvider
89 * @param string|integer $input Given input
90 * @param integer $expected Expected result
91 * @return void
92 */
93 public function getCategoryIndexFromStringOrNumberReturnsIndex($input, $expected) {
94 $extension = new \TYPO3\CMS\Extensionmanager\Domain\Model\Extension;
95 $this->assertEquals($expected, $extension->getCategoryIndexFromStringOrNumber($input));
96 }
97 }