PageRenderTime 81ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/Tests/Unit/Package/PackageManagerTest.php

https://github.com/christianjul/FLOW3-Composer
PHP | 509 lines | 335 code | 76 blank | 98 comment | 0 complexity | 163fa8876831587fa8406911649f6003 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-3.0
  1. <?php
  2. namespace TYPO3\FLOW3\Tests\Unit\Package;
  3. /* *
  4. * This script belongs to the FLOW3 framework. *
  5. * *
  6. * It is free software; you can redistribute it and/or modify it under *
  7. * the terms of the GNU Lesser General Public License, either version 3 *
  8. * of the License, or (at your option) any later version. *
  9. * *
  10. * The TYPO3 project - inspiring people to share! *
  11. * */
  12. use TYPO3\FLOW3\Package\PackageInterface;
  13. /**
  14. * Testcase for the default package manager
  15. *
  16. */
  17. class PackageManagerTest extends \TYPO3\FLOW3\Tests\UnitTestCase {
  18. /**
  19. * @var \TYPO3\FLOW3\Package\PackageManager
  20. */
  21. protected $packageManager;
  22. /**
  23. * Sets up this test case
  24. *
  25. */
  26. protected function setUp() {
  27. \vfsStreamWrapper::register();
  28. \vfsStreamWrapper::setRoot(new \vfsStreamDirectory('Test'));
  29. $mockBootstrap = $this->getMock('TYPO3\FLOW3\Core\Bootstrap', array(), array(), '', FALSE);
  30. $mockBootstrap->expects($this->any())->method('getSignalSlotDispatcher')->will($this->returnValue($this->getMock('TYPO3\FLOW3\SignalSlot\Dispatcher')));
  31. $this->packageManager = new \TYPO3\FLOW3\Package\PackageManager();
  32. mkdir('vfs://Test/Resources');
  33. $packageClassTemplateUri = 'vfs://Test/Resources/Package.php.tmpl';
  34. file_put_contents($packageClassTemplateUri, '<?php namespace {packageNamespace}; # The {packageKey} package');
  35. $this->packageManager->setPackageClassTemplateUri($packageClassTemplateUri);
  36. mkdir('vfs://Test/Packages/Application', 0700, TRUE);
  37. mkdir('vfs://Test/Configuration');
  38. $mockClassLoader = $this->getMock('TYPO3\FLOW3\Core\ClassLoader');
  39. $this->packageManager->injectClassLoader($mockClassLoader);
  40. $this->packageManager->initialize($mockBootstrap, 'vfs://Test/Packages/', 'vfs://Test/Configuration/PackageStates.php');
  41. }
  42. /**
  43. * @test
  44. */
  45. public function initializeUsesPackageStatesConfigurationForActivePackages() {
  46. }
  47. /**
  48. * @test
  49. */
  50. public function getPackageReturnsTheSpecifiedPackage() {
  51. $this->packageManager->createPackage('TYPO3.FLOW3');
  52. $package = $this->packageManager->getPackage('TYPO3.FLOW3');
  53. $this->assertInstanceOf('TYPO3\FLOW3\Package\PackageInterface', $package, 'The result of getPackage() was no valid package object.');
  54. }
  55. /**
  56. * @test
  57. * @expectedException \TYPO3\FLOW3\Package\Exception\UnknownPackageException
  58. */
  59. public function getPackageThrowsExcpetionOnUnknownPackage() {
  60. $this->packageManager->getPackage('PrettyUnlikelyThatThisPackageExists');
  61. }
  62. /**
  63. * @test
  64. */
  65. public function getCaseSensitivePackageKeyReturnsTheUpperCamelCaseVersionOfAGivenPackageKeyIfThePackageIsRegistered() {
  66. $packageManager = $this->getAccessibleMock('TYPO3\FLOW3\Package\PackageManager', array('dummy'));
  67. $packageManager->_set('packageKeys', array('acme.testpackage' => 'Acme.TestPackage'));
  68. $this->assertEquals('Acme.TestPackage', $packageManager->getCaseSensitivePackageKey('acme.testpackage'));
  69. }
  70. /**
  71. * @test
  72. */
  73. public function scanAvailablePackagesTraversesThePackagesDirectoryAndRegistersPackagesItFinds() {
  74. $expectedPackageKeys = array(
  75. 'TYPO3.FLOW3' . md5(uniqid(mt_rand(), TRUE)),
  76. 'TYPO3.FLOW3.Test' . md5(uniqid(mt_rand(), TRUE)),
  77. 'TYPO3.YetAnotherTestPackage' . md5(uniqid(mt_rand(), TRUE)),
  78. 'RobertLemke.FLOW3.NothingElse' . md5(uniqid(mt_rand(), TRUE))
  79. );
  80. foreach ($expectedPackageKeys as $packageKey) {
  81. $packageNamespace = str_replace('.', '\\', $packageKey);
  82. $packagePath = 'vfs://Test/Packages/Application/' . $packageKey . '/';
  83. $packageClassCode = '<?php
  84. namespace ' . $packageNamespace . ';
  85. class Package extends \TYPO3\FLOW3\Package\Package {}
  86. ?>';
  87. mkdir($packagePath, 0770, TRUE);
  88. mkdir($packagePath . 'Classes');
  89. mkdir($packagePath . 'Meta');
  90. file_put_contents($packagePath . 'Classes/Package.php', $packageClassCode);
  91. file_put_contents($packagePath . 'Meta/Package.xml', '<xml>...</xml>');
  92. }
  93. $packageManager = $this->getAccessibleMock('TYPO3\FLOW3\Package\PackageManager', array('dummy'));
  94. $packageManager->_set('packagesBasePath', 'vfs://Test/Packages/');
  95. $packageManager->_set('packageStatesPathAndFilename', 'vfs://Test/Configuration/PackageStates.php');
  96. $packageManager->_set('packages', array());
  97. $packageManager->_call('scanAvailablePackages');
  98. $packageStates = require('vfs://Test/Configuration/PackageStates.php');
  99. $actualPackageKeys = array_keys($packageStates['packages']);
  100. $this->assertEquals(sort($expectedPackageKeys), sort($actualPackageKeys));
  101. }
  102. /**
  103. * @test
  104. */
  105. public function scanAvailablePackagesKeepsExistingPackageConfiguration() {
  106. $expectedPackageKeys = array(
  107. 'TYPO3.FLOW3' . md5(uniqid(mt_rand(), TRUE)),
  108. 'TYPO3.FLOW3.Test' . md5(uniqid(mt_rand(), TRUE)),
  109. 'TYPO3.YetAnotherTestPackage' . md5(uniqid(mt_rand(), TRUE)),
  110. 'RobertLemke.FLOW3.NothingElse' . md5(uniqid(mt_rand(), TRUE))
  111. );
  112. foreach ($expectedPackageKeys as $packageKey) {
  113. $packageNamespace = str_replace('.', '\\', $packageKey);
  114. $packagePath = 'vfs://Test/Packages/Application/' . $packageKey . '/';
  115. $packageClassCode = '<?php
  116. namespace ' . $packageNamespace . ';
  117. class Package extends \TYPO3\FLOW3\Package\Package {}
  118. ?>';
  119. mkdir($packagePath, 0770, TRUE);
  120. mkdir($packagePath . 'Classes');
  121. mkdir($packagePath . 'Meta');
  122. file_put_contents($packagePath . 'Classes/Package.php', $packageClassCode);
  123. file_put_contents($packagePath . 'Meta/Package.xml', '<xml>...</xml>');
  124. }
  125. $packageManager = $this->getAccessibleMock('TYPO3\FLOW3\Package\PackageManager', array('dummy'));
  126. $packageManager->_set('packagesBasePath', 'vfs://Test/Packages/');
  127. $packageManager->_set('packageStatesPathAndFilename', 'vfs://Test/Configuration/PackageStates.php');
  128. $packageManager->_set('packageStatesConfiguration', array(
  129. 'packages' => array(
  130. $packageKey => array(
  131. 'state' => 'inactive',
  132. 'frozen' => FALSE,
  133. 'packagePath' => 'Application/' . $packageKey . '/',
  134. 'classesPath' => 'Classes/'
  135. )
  136. ),
  137. 'version' => 2
  138. ));
  139. $packageManager->_call('scanAvailablePackages');
  140. $packageStates = require('vfs://Test/Configuration/PackageStates.php');
  141. $this->assertEquals('inactive', $packageStates['packages'][$packageKey]['state']);
  142. }
  143. /**
  144. * @test
  145. */
  146. public function packageStatesConfigurationContainsRelativePaths() {
  147. $packageKeys = array(
  148. 'RobertLemke.FLOW3.NothingElse' . md5(uniqid(mt_rand(), TRUE)),
  149. 'TYPO3.FLOW3' . md5(uniqid(mt_rand(), TRUE)),
  150. 'TYPO3.YetAnotherTestPackage' . md5(uniqid(mt_rand(), TRUE)),
  151. );
  152. foreach ($packageKeys as $packageKey) {
  153. $packageNamespace = str_replace('.', '\\', $packageKey);
  154. $packagePath = 'vfs://Test/Packages/Application/' . str_replace('.', '/', $packageNamespace) . '/';
  155. $packageClassCode = '<?php
  156. namespace ' . $packageNamespace . ';
  157. class Package extends \TYPO3\FLOW3\Package\Package {}
  158. ?>';
  159. mkdir($packagePath, 0770, TRUE);
  160. mkdir($packagePath . 'Classes');
  161. mkdir($packagePath . 'Meta');
  162. file_put_contents($packagePath . 'Classes/Package.php', $packageClassCode);
  163. file_put_contents($packagePath . 'Meta/Package.xml', '<xml>...</xml>');
  164. }
  165. $packageManager = $this->getAccessibleMock('TYPO3\FLOW3\Package\PackageManager', array('updateShortcuts'), array(), '', FALSE);
  166. $packageManager->_set('packagesBasePath', 'vfs://Test/Packages/');
  167. $packageManager->_set('packageStatesPathAndFilename', 'vfs://Test/Configuration/PackageStates.php');
  168. $packageManager->_set('packages', array());
  169. $packageManager->_call('scanAvailablePackages');
  170. $expectedPackageStatesConfiguration = array();
  171. foreach ($packageKeys as $packageKey) {
  172. $expectedPackageStatesConfiguration[$packageKey] = array(
  173. 'state' => 'active',
  174. 'packagePath' => 'Application/' . str_replace('.', '/', $packageKey) . '/',
  175. 'classesPath' => 'Classes/'
  176. );
  177. }
  178. $actualPackageStatesConfiguration = $packageManager->_get('packageStatesConfiguration');
  179. $this->assertEquals($expectedPackageStatesConfiguration, $actualPackageStatesConfiguration['packages']);
  180. }
  181. /**
  182. * Data Provider returning valid package keys and the corresponding path
  183. *
  184. * @return array
  185. */
  186. public function packageKeysAndPaths() {
  187. return array(
  188. array('TYPO3.YetAnotherTestPackage', 'vfs://Test/Packages/Application/TYPO3.YetAnotherTestPackage/'),
  189. array('RobertLemke.FLOW3.NothingElse', 'vfs://Test/Packages/Application/RobertLemke.FLOW3.NothingElse/')
  190. );
  191. }
  192. /**
  193. * @test
  194. * @dataProvider packageKeysAndPaths
  195. */
  196. public function createPackageCreatesPackageFolderAndReturnsPackage($packageKey, $expectedPackagePath) {
  197. $actualPackage = $this->packageManager->createPackage($packageKey);
  198. $actualPackagePath = $actualPackage->getPackagePath();
  199. $this->assertEquals($expectedPackagePath, $actualPackagePath);
  200. $this->assertTrue(is_dir($actualPackagePath), 'Package path should exist after createPackage()');
  201. $this->assertEquals($packageKey, $actualPackage->getPackageKey());
  202. $this->assertTrue($this->packageManager->isPackageAvailable($packageKey));
  203. }
  204. /**
  205. * @test
  206. */
  207. public function createPackageWritesAPackageMetaFileUsingTheGivenMetaObject() {
  208. $metaData = new \TYPO3\FLOW3\Package\MetaData('Acme.YetAnotherTestPackage');
  209. $metaData->setTitle('Yet Another Test Package');
  210. $package = $this->packageManager->createPackage('Acme.YetAnotherTestPackage', $metaData);
  211. $actualPackageXml = simplexml_load_file($package->getMetaPath() . 'Package.xml');
  212. $this->assertEquals('Acme.YetAnotherTestPackage', (string)$actualPackageXml->key);
  213. $this->assertEquals('Yet Another Test Package', (string)$actualPackageXml->title);
  214. }
  215. /**
  216. * Checks if createPackage() creates the folders for classes, configuration, documentation, resources and tests and
  217. * the mandatory Package class.
  218. *
  219. * @test
  220. */
  221. public function createPackageCreatesCommonFoldersAndThePackageClass() {
  222. $package = $this->packageManager->createPackage('Acme.YetAnotherTestPackage');
  223. $packagePath = $package->getPackagePath();
  224. $this->assertTrue(is_dir($packagePath . PackageInterface::DIRECTORY_CLASSES), "Classes directory was not created");
  225. $this->assertTrue(is_dir($packagePath . PackageInterface::DIRECTORY_CONFIGURATION), "Configuration directory was not created");
  226. $this->assertTrue(is_dir($packagePath . PackageInterface::DIRECTORY_DOCUMENTATION), "Documentation directory was not created");
  227. $this->assertTrue(is_dir($packagePath . PackageInterface::DIRECTORY_RESOURCES), "Resources directory was not created");
  228. $this->assertTrue(is_dir($packagePath . PackageInterface::DIRECTORY_TESTS_UNIT), "Tests/Unit directory was not created");
  229. $this->assertTrue(is_dir($packagePath . PackageInterface::DIRECTORY_TESTS_FUNCTIONAL), "Tests/Functional directory was not created");
  230. $this->assertTrue(is_dir($packagePath . PackageInterface::DIRECTORY_METADATA), "Metadata directory was not created");
  231. $actualPackageClassCode = file_get_contents($packagePath . PackageInterface::DIRECTORY_CLASSES . 'Package.php');
  232. $expectedPackageClassCode = '<?php namespace Acme\YetAnotherTestPackage; # The Acme.YetAnotherTestPackage package';
  233. $this->assertEquals($expectedPackageClassCode, $actualPackageClassCode);
  234. }
  235. /**
  236. * Makes sure that an exception is thrown and no directory is created on passing invalid package keys.
  237. *
  238. * @test
  239. */
  240. public function createPackageThrowsExceptionOnInvalidPackageKey() {
  241. try {
  242. $this->packageManager->createPackage('Invalid_PackageKey');
  243. } catch (\TYPO3\FLOW3\Package\Exception\InvalidPackageKeyException $exception) {
  244. }
  245. $this->assertFalse(is_dir('vfs://Test/Packages/Application/Invalid_PackageKey'), 'Package folder with invalid package key was created');
  246. }
  247. /**
  248. * Makes sure that duplicate package keys are detected.
  249. *
  250. * @test
  251. * @expectedException TYPO3\FLOW3\Package\Exception\PackageKeyAlreadyExistsException
  252. */
  253. public function createPackageThrowsExceptionForExistingPackageKey() {
  254. $this->packageManager->createPackage('Acme.YetAnotherTestPackage');
  255. $this->packageManager->createPackage('Acme.YetAnotherTestPackage');
  256. }
  257. /**
  258. * @test
  259. */
  260. public function createPackageActivatesTheNewlyCreatedPackage() {
  261. $this->packageManager->createPackage('Acme.YetAnotherTestPackage');
  262. $this->assertTrue($this->packageManager->isPackageActive('Acme.YetAnotherTestPackage'));
  263. }
  264. /**
  265. * @test
  266. */
  267. public function activatePackageAndDeactivatePackageActivateAndDeactivateTheGivenPackage() {
  268. $packageKey = 'Acme.YetAnotherTestPackage';
  269. $this->packageManager->createPackage($packageKey);
  270. $this->packageManager->deactivatePackage($packageKey);
  271. $this->assertFalse($this->packageManager->isPackageActive($packageKey));
  272. $this->packageManager->activatePackage($packageKey);
  273. $this->assertTrue($this->packageManager->isPackageActive($packageKey));
  274. }
  275. /**
  276. * @test
  277. * @expectedException \TYPO3\FLOW3\Package\Exception\ProtectedPackageKeyException
  278. */
  279. public function deactivatePackageThrowsAnExceptionIfPackageIsProtected() {
  280. $package = $this->packageManager->createPackage('Acme.YetAnotherTestPackage');
  281. $package->setProtected(TRUE);
  282. $this->packageManager->deactivatePackage('Acme.YetAnotherTestPackage');
  283. }
  284. /**
  285. * @test
  286. * @expectedException \TYPO3\FLOW3\Package\Exception\UnknownPackageException
  287. */
  288. public function deletePackageThrowsErrorIfPackageIsNotAvailable() {
  289. $this->packageManager->deletePackage('PrettyUnlikelyThatThisPackageExists');
  290. }
  291. /**
  292. * @test
  293. * @expectedException \TYPO3\FLOW3\Package\Exception\ProtectedPackageKeyException
  294. */
  295. public function deletePackageThrowsAnExceptionIfPackageIsProtected() {
  296. $package = $this->packageManager->createPackage('Acme.YetAnotherTestPackage');
  297. $package->setProtected(TRUE);
  298. $this->packageManager->deletePackage('Acme.YetAnotherTestPackage');
  299. }
  300. /**
  301. * @test
  302. */
  303. public function deletePackageRemovesPackageFromAvailableAndActivePackagesAndDeletesThePackageDirectory() {
  304. $package = $this->packageManager->createPackage('Acme.YetAnotherTestPackage');
  305. $packagePath = $package->getPackagePath();
  306. $this->assertTrue(is_dir($packagePath . PackageInterface::DIRECTORY_METADATA));
  307. $this->assertTrue($this->packageManager->isPackageActive('Acme.YetAnotherTestPackage'));
  308. $this->assertTrue($this->packageManager->isPackageAvailable('Acme.YetAnotherTestPackage'));
  309. $this->packageManager->deletePackage('Acme.YetAnotherTestPackage');
  310. $this->assertFalse(is_dir($packagePath . PackageInterface::DIRECTORY_METADATA));
  311. $this->assertFalse($this->packageManager->isPackageActive('Acme.YetAnotherTestPackage'));
  312. $this->assertFalse($this->packageManager->isPackageAvailable('Acme.YetAnotherTestPackage'));
  313. }
  314. /**
  315. * @test
  316. */
  317. public function getDependencyArrayForPackageReturnsCorrectResult() {
  318. $mockFlow3Metadata = $this->getMock('TYPO3\FLOW3\Package\MetaDataInterface');
  319. $mockFlow3Metadata->expects($this->any())->method('getConstraintsByType')->will($this->returnValue(array(
  320. new \TYPO3\FLOW3\Package\MetaData\PackageConstraint('depends', 'TYPO3.Fluid'),
  321. new \TYPO3\FLOW3\Package\MetaData\PackageConstraint('depends', 'Doctrine.ORM')
  322. )));
  323. $mockFlow3Package = $this->getMock('TYPO3\FLOW3\Package\PackageInterface');
  324. $mockFlow3Package->expects($this->any())->method('getPackageMetaData')->will($this->returnValue($mockFlow3Metadata));
  325. $mockFluidMetadata = $this->getMock('TYPO3\FLOW3\Package\MetaDataInterface');
  326. $mockFluidMetadata->expects($this->any())->method('getConstraintsByType')->will($this->returnValue(array(
  327. new \TYPO3\FLOW3\Package\MetaData\PackageConstraint('depends', 'TYPO3.FLOW3')
  328. )));
  329. $mockFluidPackage = $this->getMock('TYPO3\FLOW3\Package\PackageInterface');
  330. $mockFluidPackage->expects($this->any())->method('getPackageMetaData')->will($this->returnValue($mockFluidMetadata));
  331. $mockOrmMetadata = $this->getMock('TYPO3\FLOW3\Package\MetaDataInterface');
  332. $mockOrmMetadata->expects($this->any())->method('getConstraintsByType')->will($this->returnValue(array(
  333. new \TYPO3\FLOW3\Package\MetaData\PackageConstraint('depends', 'Doctrine.DBAL')
  334. )));
  335. $mockOrmPackage = $this->getMock('TYPO3\FLOW3\Package\PackageInterface');
  336. $mockOrmPackage->expects($this->any())->method('getPackageMetaData')->will($this->returnValue($mockOrmMetadata));
  337. $mockDbalMetadata = $this->getMock('TYPO3\FLOW3\Package\MetaDataInterface');
  338. $mockDbalMetadata->expects($this->any())->method('getConstraintsByType')->will($this->returnValue(array(
  339. new \TYPO3\FLOW3\Package\MetaData\PackageConstraint('depends', 'Doctrine.Common')
  340. )));
  341. $mockDbalPackage = $this->getMock('TYPO3\FLOW3\Package\PackageInterface');
  342. $mockDbalPackage->expects($this->any())->method('getPackageMetaData')->will($this->returnValue($mockDbalMetadata));
  343. $mockCommonMetadata = $this->getMock('TYPO3\FLOW3\Package\MetaDataInterface');
  344. $mockCommonMetadata->expects($this->any())->method('getConstraintsByType')->will($this->returnValue(array()));
  345. $mockCommonPackage = $this->getMock('TYPO3\FLOW3\Package\PackageInterface');
  346. $mockCommonPackage->expects($this->any())->method('getPackageMetaData')->will($this->returnValue($mockCommonMetadata));
  347. $packages = array(
  348. 'TYPO3.FLOW3' => $mockFlow3Package,
  349. 'TYPO3.Fluid' => $mockFluidPackage,
  350. 'Doctrine.ORM' => $mockOrmPackage,
  351. 'Doctrine.DBAL' => $mockDbalPackage,
  352. 'Doctrine.Common' => $mockCommonPackage
  353. );
  354. $packageManager = $this->getAccessibleMock('\TYPO3\FLOW3\Package\PackageManager', array('dummy'));
  355. $packageManager->_set('packages', $packages);
  356. $dependencyArray = $packageManager->_call('getDependencyArrayForPackage', 'TYPO3.FLOW3');
  357. $this->assertEquals(array('Doctrine.Common', 'Doctrine.DBAL', 'Doctrine.ORM', 'TYPO3.Fluid'), $dependencyArray);
  358. }
  359. /**
  360. * @test
  361. */
  362. public function sortAvailablePackagesByDependenciesMakesSureThatDependantPackagesAreStandingBeforeAPackageInTheInternalPackagesAndPackagesConfigurationArrays() {
  363. $doctrineCommon = $this->getMock('\TYPO3\FLOW3\Package\PackageInterface');
  364. $doctrineCommon->expects($this->any())->method('getPackageKey')->will($this->returnValue('Doctrine.Common'));
  365. $doctrineDbal = $this->getMock('\TYPO3\FLOW3\Package\PackageInterface');
  366. $doctrineDbal->expects($this->any())->method('getPackageKey')->will($this->returnValue('Doctrine.DBAL'));
  367. $doctrineOrm = $this->getMock('\TYPO3\FLOW3\Package\PackageInterface');
  368. $doctrineOrm->expects($this->any())->method('getPackageKey')->will($this->returnValue('Doctrine.ORM'));
  369. $typo3Flow3 = $this->getMock('\TYPO3\FLOW3\Package\PackageInterface');
  370. $typo3Flow3->expects($this->any())->method('getPackageKey')->will($this->returnValue('TYPO3.FLOW3'));
  371. $symfonyComponentYaml = $this->getMock('\TYPO3\FLOW3\Package\PackageInterface');
  372. $symfonyComponentYaml->expects($this->any())->method('getPackageKey')->will($this->returnValue('Symfony.Component.Yaml'));
  373. $unsortedPackageStatesConfiguration = array('packages' =>
  374. array(
  375. 'Doctrine.ORM' => array(
  376. 'dependencies' => array('Doctrine.Common', 'Doctrine.DBAL')
  377. ),
  378. 'Symfony.Component.Yaml' => array(
  379. 'dependencies' => array()
  380. ),
  381. 'TYPO3.FLOW3' => array(
  382. 'dependencies' => array('Symfony.Component.Yaml', 'Doctrine.Common', 'Doctrine.DBAL', 'Doctrine.ORM')
  383. ),
  384. 'Doctrine.Common' => array(
  385. 'dependencies' => array()
  386. ),
  387. 'Doctrine.DBAL' => array(
  388. 'dependencies' => array('Doctrine.Common')
  389. )
  390. )
  391. );
  392. $unsortedPackages = array(
  393. 'Doctrine.ORM' => $doctrineOrm,
  394. 'Symfony.Component.Yaml' => $symfonyComponentYaml,
  395. 'TYPO3.FLOW3' => $typo3Flow3,
  396. 'Doctrine.Common' => $doctrineCommon,
  397. 'Doctrine.DBAL' => $doctrineDbal
  398. );
  399. $packageManager = $this->getAccessibleMock('\TYPO3\FLOW3\Package\PackageManager', array('resolvePackageDependencies'));
  400. $packageManager->_set('packages', $unsortedPackages);
  401. $packageManager->_set('packageStatesConfiguration', $unsortedPackageStatesConfiguration);
  402. $packageManager->_call('sortAvailablePackagesByDependencies');
  403. $expectedSortedPackageKeys = array(
  404. 'Doctrine.Common',
  405. 'Doctrine.DBAL',
  406. 'Doctrine.ORM',
  407. 'Symfony.Component.Yaml',
  408. 'TYPO3.FLOW3'
  409. );
  410. $expectedSortedPackageStatesConfiguration = array('packages' =>
  411. array(
  412. 'Doctrine.Common' => array(
  413. 'dependencies' => array()
  414. ),
  415. 'Doctrine.DBAL' => array(
  416. 'dependencies' => array('Doctrine.Common')
  417. ),
  418. 'Doctrine.ORM' => array(
  419. 'dependencies' => array('Doctrine.Common', 'Doctrine.DBAL')
  420. ),
  421. 'Symfony.Component.Yaml' => array(
  422. 'dependencies' => array()
  423. ),
  424. 'TYPO3.FLOW3' => array(
  425. 'dependencies' => array('Symfony.Component.Yaml', 'Doctrine.Common', 'Doctrine.DBAL', 'Doctrine.ORM')
  426. )
  427. )
  428. );
  429. $this->assertEquals($expectedSortedPackageKeys, array_keys($packageManager->_get('packages')), 'The packages have not been ordered according to their dependencies!');
  430. $this->assertEquals($expectedSortedPackageStatesConfiguration, $packageManager->_get('packageStatesConfiguration'), 'The package states configurations have not been ordered according to their dependencies!');
  431. }
  432. }
  433. ?>