ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
InstallerTest.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of Component Installer.
5 *
6 * (c) Rob Loach (http://robloach.net)
7 *
8 * For the full copyright and license information, please view the LICENSE.md
9 * file that was distributed with this source code.
10 */
11
12namespace Composer\Test;
13
15use Composer\Test\Installer\LibraryInstallerTest;
17use Composer\Package\Loader\ArrayLoader;
18use Composer\Config;
19
23class InstallerTest extends LibraryInstallerTest
24{
25 protected $componentDir = 'components';
26
30 protected $config;
31
35 protected $fs;
36
40 protected function setUp()
41 {
42 // Run through the Library Installer Test set up.
43 parent::setUp();
44
45 // Also be sure to set up the Component directory.
46 $this->componentDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'composer-test-component';
47 $this->ensureDirectoryExistsAndClear($this->componentDir);
48
49 // Merge the component-dir setting in so that it applies correctly.
50 $this->config->merge(array(
51 'config' => array(
52 'component-dir' => $this->componentDir,
53 ),
54 ));
55 }
56
60 protected function tearDown()
61 {
62 $this->fs->removeDirectory($this->componentDir);
63
64 parent::tearDown();
65 }
66
71 {
72 $this->fs->removeDirectory($this->componentDir);
73 new Installer($this->io, $this->composer);
74 $this->assertFileNotExists($this->componentDir);
75 }
76
89 public function testComponentSupports($type, $expected)
90 {
91 $installer = new Installer($this->io, $this->composer, 'component');
92 $this->assertSame($expected, $installer->supports($type), sprintf('Failed to show support for %s', $type));
93 }
94
101 {
102 // All package types support having Components.
103 $tests[] = array('component', true);
104 $tests[] = array('all-supported', false);
105
106 return $tests;
107 }
108
121 public function testGetComponentPath($expected, $package) {
122 // Construct the mock objects.
123 $installer = new Installer($this->io, $this->composer, 'component');
124 $loader = new ArrayLoader();
125
126 // Test the results.
127 $result = $installer->getComponentPath($loader->load($package));
128 $this->assertEquals($this->componentDir . DIRECTORY_SEPARATOR . $expected, $result);
129 }
130
136 public function providerGetComponentPath()
137 {
138 $package = array(
139 'name' => 'foo/bar',
140 'type' => 'component',
141 'version' => '1.0.0',
142 );
143 $tests[] = array('bar', $package);
144
145 $package = array(
146 'name' => 'foo/bar2',
147 'version' => '1.0.0',
148 'type' => 'component',
149 'extra' => array(
150 'component' => array(
151 'name' => 'foo',
152 ),
153 ),
154 );
155 $tests[] = array('foo', $package);
156
157 return $tests;
158 }
159}
sprintf('%.4f', $callTime)
$result
An exception for terminatinating execution or to throw for unit testing.
Component Installer for Composer.
Definition: Installer.php:23
Provides basic file system operations.
Definition: Filesystem.php:20
Tests registering Component Installer with Composer.
providerGetComponentPath()
Data provider for testGetComponentPath().
testInstallerCreationShouldNotCreateComponentDirectory()
Tests that the Installer doesn't create the Component directory.
testComponentSupports($type, $expected)
Test the Installer's support() function.
providerComponentSupports()
Data provider for testComponentSupports().
testGetComponentPath($expected, $package)
Tests the Installer's getComponentPath function.