ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
RequireCssProcessTest.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 use Composer\Config;
16 
21 {
25  protected $process;
26 
27  public function setUp()
28  {
29  parent::setUp();
30  $this->process = new RequireCssProcess($this->composer, $this->io);
31  }
40  public function testPackageStyles(array $packages, array $config, $expected = null)
41  {
42  $this->composer->getConfig()->merge(array('config' => $config));
43  $this->process->init();
44  $result = $this->process->packageStyles($packages);
45  $this->assertEquals($expected, $result);
46  }
47 
48  public function providerPackageStyles()
49  {
50  // Test collecting one style.
51  $package = array(
52  'name' => 'components/package',
53  'type' => 'component',
54  'extra' => array(
55  'component' => array(
56  'styles' => array(
57  'tests/ComponentInstaller/Test/Resources/test.css',
58  ),
59  ),
60  ),
61  'is-root' => true,
62  );
63  $packages = array($package);
64  $expected = array(
65  'package' => array(
66  'tests/ComponentInstaller/Test/Resources/test.css' => array(
67  realpath('tests/ComponentInstaller/Test/Resources/test.css'),
68  ),
69  ),
70  );
71  $tests[] = array($packages, array(), $expected);
72 
73  // Test collecting a style that doesn't exist.
74  $package2 = array(
75  'name' => 'components/package2',
76  'type' => 'component',
77  'extra' => array(
78  'component' => array(
79  'styles' => array(
80  'tests/ComponentInstaller/Test/Resources/test-not-found.css',
81  ),
82  ),
83  ),
84  'is-root' => true,
85  );
86  $packages = array($package, $package2);
87  $expected = array(
88  'package' => array(
89  'tests/ComponentInstaller/Test/Resources/test.css' => array(
90  realpath('tests/ComponentInstaller/Test/Resources/test.css'),
91  )
92  )
93  );
94  $tests[] = array($packages, array(), $expected);
95 
96  // Test collecting a style that doesn't exist.
97  $package3 = array(
98  'name' => 'components/package3',
99  'type' => 'component',
100  'extra' => array(
101  'component' => array(
102  'styles' => array(
103  'tests/ComponentInstaller/Test/Resources/test2.css',
104  ),
105  ),
106  ),
107  'is-root' => true,
108  );
109  $packages = array($package, $package3);
110  $expected = array(
111  'package' => array(
112  'tests/ComponentInstaller/Test/Resources/test.css' => array(
113  realpath('tests/ComponentInstaller/Test/Resources/test.css'),
114  ),
115  ),
116  'package3' => array(
117  'tests/ComponentInstaller/Test/Resources/test2.css' => array(
118  realpath('tests/ComponentInstaller/Test/Resources/test2.css'),
119  ),
120  )
121  );
122  $tests[] = array($packages, array(), $expected);
123 
124  // Test collecting a style that uses glob().
125  $package = array(
126  'name' => 'components/package4',
127  'type' => 'component',
128  'extra' => array(
129  'component' => array(
130  'styles' => array(
131  'tests/ComponentInstaller/Test/Resources/*.css',
132  ),
133  ),
134  ),
135  'is-root' => true,
136  );
137  $packages = array($package);
138  $expected = array(
139  'package4' => array(
140  'tests/ComponentInstaller/Test/Resources/*.css' => array(
141  realpath('tests/ComponentInstaller/Test/Resources/test.css'),
142  realpath('tests/ComponentInstaller/Test/Resources/test2.css'),
143  )
144  )
145  );
146  $tests[] = array($packages, array(), $expected);
147 
148  return $tests;
149  }
150 }
$result
testPackageStyles(array $packages, array $config, $expected=null)
testPackageStyles
Builds the require.css file from all Component stylesheets.
Create styles array
The data for the language used.