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