ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
CopyProcessTest.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
13
15
20{
24 protected $process;
25
26 public function setUp()
27 {
28 parent::setUp();
29 $this->process = new CopyProcess($this->composer, $this->io);
30 }
31
39 public function testCopyStyles($packages, $files)
40 {
41 // Initialize the process.
42 $this->process->init();
43 $this->process->copy($packages);
44 foreach ($files as $file) {
45 $this->assertFileExists($this->componentDir.'/' . $file, sprintf('Failed to find the destination file: %s', $file));
46 }
47 }
48
49 public function providerCopyStyles()
50 {
51 // Test collecting one style.
52 $package = array(
53 'name' => 'components/package',
54 'version' => '1.2.3',
55 'is-root' => true, // Set the root so that it knows to use the cwd.
56 'extra' => array(
57 'component' => array(
58 'styles' => array(
59 'tests/ComponentInstaller/Test/Resources/test.css',
60 ),
61 ),
62 ),
63 );
64 $packages = array($package);
65 $tests[] = array($packages, array(
66 'package/tests/ComponentInstaller/Test/Resources/test.css',
67 ));
68
69 // Test collecting two styles.
70 $package = array(
71 'name' => 'components/packagewithtwostyles',
72 'version' => '1.2.3',
73 'is-root' => true, // Set the root so that it knows to use the cwd.
74 'extra' => array(
75 'component' => array(
76 'styles' => array(
77 'tests/ComponentInstaller/Test/Resources/test.css',
78 'tests/ComponentInstaller/Test/Resources/test2.css',
79 ),
80 ),
81 ),
82 );
83 $packages = array($package);
84 $tests[] = array($packages, array(
85 'packagewithtwostyles/tests/ComponentInstaller/Test/Resources/test.css',
86 'packagewithtwostyles/tests/ComponentInstaller/Test/Resources/test2.css',
87 ));
88
89 // Test collecting a style that doesn't exist.
90 $package = array(
91 'name' => 'components/stylethatdoesnotexist',
92 'version' => '1.2.3',
93 'is-root' => true, // Set the root so that it knows to use the cwd.
94 'extra' => array(
95 'component' => array(
96 'styles' => array(
97 'tests/ComponentInstaller/Test/Resources/test.css',
98 'tests/ComponentInstaller/Test/Resources/test-not-found.css',
99 ),
100 ),
101 ),
102 );
103 $packages = array($package);
104 $tests[] = array($packages, array(
105 'stylethatdoesnotexist/tests/ComponentInstaller/Test/Resources/test.css',
106 ));
107
108 // Test collecting all styles, files and scripts.
109 $package = array(
110 'name' => 'components/allassets',
111 'version' => '1.2.3',
112 'is-root' => true, // Set the root so that it knows to use the cwd.
113 'extra' => array(
114 'component' => array(
115 'styles' => array(
116 'tests/ComponentInstaller/Test/Resources/test.css',
117 ),
118 'files' => array(
119 'tests/ComponentInstaller/Test/Resources/img.jpg',
120 'tests/ComponentInstaller/Test/Resources/img2.jpg',
121 ),
122 'scripts' => array(
123 'tests/ComponentInstaller/Test/Resources/test.js'
124 ),
125 ),
126 ),
127 );
128 $packages = array($package);
129 $tests[] = array($packages, array(
130 'allassets/tests/ComponentInstaller/Test/Resources/test.css',
131 'allassets/tests/ComponentInstaller/Test/Resources/img.jpg',
132 'allassets/tests/ComponentInstaller/Test/Resources/img2.jpg',
133 'allassets/tests/ComponentInstaller/Test/Resources/test.js',
134 ));
135
136 // Test copying a different component name.
137 $package = array(
138 'name' => 'components/differentcomponentname',
139 'version' => '1.2.3',
140 'is-root' => true, // Set the root so that it knows to use the cwd.
141 'extra' => array(
142 'component' => array(
143 'name' => 'diffname',
144 'files' => array(
145 'tests/ComponentInstaller/Test/Resources/img.jpg',
146 ),
147 ),
148 ),
149 );
150 $packages = array($package);
151 $tests[] = array($packages, array(
152 'diffname/tests/ComponentInstaller/Test/Resources/img.jpg',
153 ));
154
155 // Test two different packages.
156 $package = array(
157 'name' => 'components/twopackages1',
158 'version' => '1.2.3',
159 'is-root' => true, // Set the root so that it knows to use the cwd.
160 'extra' => array(
161 'component' => array(
162 'files' => array(
163 'tests/ComponentInstaller/Test/Resources/img.jpg',
164 ),
165 ),
166 ),
167 );
168 $package2 = array(
169 'name' => 'components/twopackages2',
170 'version' => '1.2.3',
171 'is-root' => true, // Set the root so that it knows to use the cwd.
172 'extra' => array(
173 'component' => array(
174 'name' => 'twopackages2-diff',
175 'files' => array(
176 'tests/ComponentInstaller/Test/Resources/img2.jpg',
177 ),
178 ),
179 ),
180 );
181 $packages = array($package, $package2);
182 $tests[] = array($packages, array(
183 'twopackages1/tests/ComponentInstaller/Test/Resources/img.jpg',
184 'twopackages2-diff/tests/ComponentInstaller/Test/Resources/img2.jpg',
185 ));
186
187 // Test copying an asset with a glob().
188 $package = array(
189 'name' => 'components/differentcomponentname',
190 'version' => '1.2.3',
191 'is-root' => true, // Set the root so that it knows to use the cwd.
192 'extra' => array(
193 'component' => array(
194 'name' => 'diffname',
195 'files' => array(
196 'tests/ComponentInstaller/Test/Resources/*.jpg',
197 ),
198 ),
199 ),
200 );
201 $packages = array($package);
202 $tests[] = array($packages, array(
203 'diffname/tests/ComponentInstaller/Test/Resources/img.jpg',
204 'diffname/tests/ComponentInstaller/Test/Resources/img2.jpg',
205 ));
206
207 return $tests;
208 }
209}
sprintf('%.4f', $callTime)
$files
Definition: add-vimline.php:18
An exception for terminatinating execution or to throw for unit testing.
Process which copies components from their source to the components folder.
Definition: CopyProcess.php:18
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file