TYPO3 CMS  TYPO3_6-2
ListUtilityTest.php
Go to the documentation of this file.
1 <?php
3 
17 
23 
27  protected $subject;
28 
32  public function setUp() {
33  $this->subject = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility', array('emitPackagesMayHaveChangedSignal'));
34  $packageManagerMock = $this->getMock('TYPO3\\CMS\\Core\\Package\\PackageManager');
35  $packageManagerMock
36  ->expects($this->any())
37  ->method('getActivePackages')
38  ->will($this->returnValue(array(
39  'cms' => $this->getMock('TYPO3\\CMS\\Cms\\Package', array(), array(), '', FALSE),
40  'lang' => $this->getMock('TYPO3\\CMS\\Cms\\Package', array(), array(), '', FALSE),
41  'news' => $this->getMock('TYPO3\\CMS\\Cms\\Package', array(), array(), '', FALSE),
42  'saltedpasswords' => $this->getMock('TYPO3\\CMS\\Cms\\Package', array(), array(), '', FALSE),
43  'rsaauth' => $this->getMock('TYPO3\\CMS\\Cms\\Package', array(), array(), '', FALSE),
44  )));
45  $this->inject($this->subject, 'packageManager', $packageManagerMock);
46  }
47 
52  return array(
53  'same extension lists' => array(
54  array(
55  'cms' => array(),
56  'lang' => array(),
57  'news' => array(),
58  'saltedpasswords' => array(),
59  'rsaauth' => array()
60  ),
61  array(
62  'cms' => array('installed' => TRUE),
63  'lang' => array('installed' => TRUE),
64  'news' => array('installed' => TRUE),
65  'saltedpasswords' => array('installed' => TRUE),
66  'rsaauth' => array('installed' => TRUE)
67  )
68  ),
69  'different extension lists' => array(
70  array(
71  'cms' => array(),
72  'lang' => array(),
73  'news' => array(),
74  'saltedpasswords' => array(),
75  'rsaauth' => array()
76  ),
77  array(
78  'cms' => array('installed' => TRUE),
79  'lang' => array('installed' => TRUE),
80  'news' => array('installed' => TRUE),
81  'saltedpasswords' => array('installed' => TRUE),
82  'rsaauth' => array('installed' => TRUE)
83  )
84  ),
85  'different extension lists - set2' => array(
86  array(
87  'cms' => array(),
88  'lang' => array(),
89  'news' => array(),
90  'saltedpasswords' => array(),
91  'rsaauth' => array(),
92  'em' => array()
93  ),
94  array(
95  'cms' => array('installed' => TRUE),
96  'lang' => array('installed' => TRUE),
97  'news' => array('installed' => TRUE),
98  'saltedpasswords' => array('installed' => TRUE),
99  'rsaauth' => array('installed' => TRUE),
100  'em' => array()
101  )
102  ),
103  'different extension lists - set3' => array(
104  array(
105  'cms' => array(),
106  'lang' => array(),
107  'fluid' => array(),
108  'news' => array(),
109  'saltedpasswords' => array(),
110  'rsaauth' => array(),
111  'em' => array()
112  ),
113  array(
114  'cms' => array('installed' => TRUE),
115  'lang' => array('installed' => TRUE),
116  'fluid' => array(),
117  'news' => array('installed' => TRUE),
118  'saltedpasswords' => array('installed' => TRUE),
119  'rsaauth' => array('installed' => TRUE),
120  'em' => array()
121  )
122  )
123  );
124  }
125 
133  public function getAvailableAndInstalledExtensionsTest($availableExtensions, $expectedResult) {
134  $this->assertEquals($expectedResult, $this->subject->getAvailableAndInstalledExtensions($availableExtensions));
135  }
136 
141  return array(
142  'simple key value array emconf' => array(
143  array(
144  'cms' => array('test' => 'test2'),
145  'lang' => array('property1' => 'oldvalue'),
146  'news' => array(),
147  'saltedpasswords' => array(),
148  'rsaauth' => array()
149  ),
150  array(
151  'property1' => 'property value1'
152  ),
153  array(
154  'cms' => array('test' => 'test2', 'property1' => 'property value1'),
155  'lang' => array('property1' => 'oldvalue'),
156  'news' => array('property1' => 'property value1'),
157  'saltedpasswords' => array('property1' => 'property value1'),
158  'rsaauth' => array('property1' => 'property value1')
159  )
160  )
161  );
162  }
163 
172  public function enrichExtensionsWithEmConfInformation($extensions, $emConf, $expectedResult) {
173  $this->inject($this->subject, 'extensionRepository', $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array('findOneByExtensionKeyAndVersion', 'findHighestAvailableVersion'), array(), '', FALSE));
174  $emConfUtilityMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\EmConfUtility');
175  $emConfUtilityMock->expects($this->any())->method('includeEmConf')->will($this->returnValue($emConf));
176  $this->inject($this->subject, 'emConfUtility', $emConfUtilityMock);
177  $this->assertEquals($expectedResult, $this->subject->enrichExtensionsWithEmConfAndTerInformation($extensions));
178  }
179 }
inject($target, $name, $dependency)
enrichExtensionsWithEmConfInformation($extensions, $emConf, $expectedResult)
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
getAvailableAndInstalledExtensionsTest($availableExtensions, $expectedResult)