Completed
Pull Request — master (#159)
by
unknown
02:05
created

testInstallAndMergeInfoWithBowerJsonContents()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 45
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 45
rs 8.8571
c 1
b 0
f 0
cc 1
eloc 28
nc 1
nop 0
1
<?php
2
3
namespace Bowerphp\Test\Installer;
4
5
use Bowerphp\Installer\Installer;
6
use Bowerphp\Test\TestCase;
7
use Mockery;
8
9
class InstallerTest extends TestCase
10
{
11
    protected $installer;
12
    protected $zipArchive;
13
    protected $config;
14
15
    protected function setUp()
16
    {
17
        parent::setUp();
18
19
        $this->zipArchive = Mockery::mock('Bowerphp\Util\ZipArchive');
20
        $this->config = Mockery::mock('Bowerphp\Config\ConfigInterface');
21
22
        $this->installer = new Installer($this->filesystem, $this->zipArchive, $this->config);
0 ignored issues
show
Compatibility introduced by
$this->zipArchive of type object<Mockery\MockInterface> is not a sub-type of object<Bowerphp\Util\ZipArchive>. It seems like you assume a concrete implementation of the interface Mockery\MockInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
23
24
        $this->config
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Mockery\Expectation>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
25
            ->shouldReceive('getOverridesSection')->andReturn([])
26
            ->shouldReceive('getOverrideFor')->andReturn([])
27
            ->shouldReceive('getBasePackagesUrl')->andReturn('http://bower.herokuapp.com/packages/')
28
            ->shouldReceive('getInstallDir')->andReturn(getcwd() . '/bower_components')
29
            ->shouldReceive('getCacheDir')->andReturn('.');
30
    }
31
32
    public function testInstall()
33
    {
34
        $package = Mockery::mock('Bowerphp\Package\PackageInterface');
35
36
        $package
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Mockery\Expectation>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
            ->shouldReceive('getName')->andReturn('jquery')
38
            ->shouldReceive('getInfo')->andReturn(['name' => 'jquery', 'version' => '2.0.3'])
39
            ->shouldReceive('getVersion')->andReturn('2.0.3')
40
            ->shouldReceive('getRequiredVersion')->andReturn('2.0.3');
41
42
        $this->zipArchive
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Mockery\Expectation>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
43
            ->shouldReceive('open')->with('./tmp/jquery')->andReturn(true)
44
            ->shouldReceive('getNumFiles')->andReturn(1)
45
            ->shouldReceive('getNameIndex')->with(0)->andReturn('jquery')
46
            ->shouldReceive('statIndex')->andReturn(['name' => 'jquery/foo', 'size' => 10, 'mtime' => 1396303200])
47
            ->shouldReceive('getStream')->with('jquery/foo')->andReturn('foo content')
48
            ->shouldReceive('close');
49
50
        $json = '{
51
    "name": "jquery",
52
    "version": "2.0.3"
53
}';
54
55
        $this->filesystem
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Mockery\Expectation>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
56
            ->shouldReceive('exists')->with(getcwd() . '/bower_components/jquery/bower.json')->andReturn(false)
57
            ->shouldReceive('write')->with(getcwd() . '/bower_components/jquery/foo', 'foo content')
58
            ->shouldReceive('write')->with(getcwd() . '/bower_components/jquery/.bower.json', $json)
59
            ->shouldReceive('touch')->with(getcwd() . '/bower_components/jquery/foo', 1396303200);
60
61
        $this->installer->install($package);
62
    }
63
64
    public function testUpdate()
65
    {
66
        $package = Mockery::mock('Bowerphp\Package\PackageInterface');
67
68
        $package
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Mockery\Expectation>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
69
            ->shouldReceive('getName')->andReturn('jquery')
70
            ->shouldReceive('getInfo')->andReturn(['name' => 'jquery', 'version' => '2.0.3'])
71
            ->shouldReceive('getRequiredVersion')->andReturn('2.0.3')
72
            ->shouldReceive('getVersion')->andReturn('2.0.3');
73
74
        $this->zipArchive
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Mockery\Expectation>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
75
            ->shouldReceive('open')->with('./tmp/jquery')->andReturn(true)
76
            ->shouldReceive('getNumFiles')->andReturn(1)
77
            ->shouldReceive('getNameIndex')->with(0)->andReturn('')
78
            ->shouldReceive('statIndex')->andReturn(['name' => 'jquery/foo', 'size' => 10, 'mtime' => 1396303200])
79
            ->shouldReceive('getStream')->with('jquery/foo')->andReturn('foo content')
80
            ->shouldReceive('close');
81
82
        $json = '{
83
    "name": "jquery",
84
    "version": "2.0.3"
85
}';
86
87
        $this->filesystem
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Mockery\Expectation>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
88
            ->shouldReceive('exists')->with(getcwd() . '/bower_components/jquery/bower.json')->andReturn(false)
89
            ->shouldReceive('write')->with(getcwd() . '/bower_components/jquery/foo', 'foo content')
90
            ->shouldReceive('write')->with(getcwd() . '/bower_components/jquery/.bower.json', $json)
91
            ->shouldReceive('touch')->with(getcwd() . '/bower_components/jquery/foo', 1396303200);
92
93
        $this->installer->update($package);
94
    }
95
96
    public function testInstallAndMergeInfoWithBowerJsonContents()
97
    {
98
        $package = Mockery::mock('Bowerphp\Package\PackageInterface');
99
100
        $info = [
101
            'name'    => 'jquery-ui',
102
            'version' => '1.12.1',
103
            'dependencies' => [
104
                'jquery' => '>=1.6',
105
            ]
106
        ];
107
108
        $package
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Mockery\Expectation>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
109
            ->shouldReceive('getName')->andReturn('jquery-ui')
110
            ->shouldReceive('getVersion')->andReturn('1.12.1')
111
            ->shouldReceive('getInfo')->andReturn([])->once()
112
            ->shouldReceive('setInfo')->with($info)->andReturnSelf()
113
            ->shouldReceive('getInfo')->andReturn($info);
114
115
        $json = '{
116
    "name": "jquery-ui",
117
    "version": "1.12.1",
118
    "dependencies": {
119
        "jquery": ">=1.6"
120
    }
121
}';
122
123
        $this->zipArchive
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Mockery\Expectation>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
124
            ->shouldReceive('open')->with('./tmp/jquery-ui')->andReturn(true)
125
            ->shouldReceive('getNumFiles')->andReturn(1)
126
            ->shouldReceive('getNameIndex')->with(0)->andReturn('jquery-ui')
127
            ->shouldReceive('statIndex')->andReturn(['name' => 'jquery-ui/bower.json', 'size' => 107, 'mtime' => 1483795099])
128
            ->shouldReceive('getStream')->with('jquery-ui/bower.json')->andReturn($json)
129
            ->shouldReceive('close');
130
131
        $this->filesystem
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Mockery\Expectation>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
132
            ->shouldReceive('exists')->with(getcwd() . '/bower_components/jquery-ui/bower.json')->andReturn(true)
133
            ->shouldReceive('write')->with(getcwd() . '/bower_components/jquery-ui/.bower.json', $json)
134
            ->shouldReceive('write')->with(getcwd() . '/bower_components/jquery-ui/bower.json', $json)
135
            ->shouldReceive('touch')->with(getcwd() . '/bower_components/jquery-ui/bower.json', 1483795099)
136
            ->shouldReceive('read')->with(getcwd() . '/bower_components/jquery-ui/bower.json')->andReturn($json)
137
        ;
138
139
        $this->installer->install($package);
140
    }
141
142
    /**
143
     * @expectedException        \RuntimeException
144
     * @expectedExceptionMessage Unable to open zip file ./tmp/jquery.
145
     */
146
    public function testInstallZipOpenException()
147
    {
148
        $package = Mockery::mock('Bowerphp\Package\PackageInterface');
149
150
        $package
151
            ->shouldReceive('getName')->andReturn('jquery');
152
153
        $this->zipArchive
154
            ->shouldReceive('open')->with('./tmp/jquery')->andReturn(false);
155
156
        $this->installer->install($package);
157
    }
158
159
    /**
160
     * @expectedException        \RuntimeException
161
     * @expectedExceptionMessage Unable to open zip file ./tmp/jquery.
162
     */
163
    public function testUpdateZipOpenException()
164
    {
165
        $package = Mockery::mock('Bowerphp\Package\PackageInterface');
166
167
        $package
168
            ->shouldReceive('getName')->andReturn('jquery');
169
170
        $this->zipArchive
171
            ->shouldReceive('open')->with('./tmp/jquery')->andReturn(false);
172
173
        $this->installer->update($package);
174
    }
175
176
    public function testFilterZipFiles()
177
    {
178
        $archive = Mockery::mock('Bowerphp\Util\ZipArchive');
179
        $archive
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Mockery\Expectation>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
180
            ->shouldReceive('getNameIndex')->with(0)->andReturn('dir/')
181
            ->shouldReceive('getNumFiles')->andReturn(12)
182
            ->shouldReceive('statIndex')->times(12)->andReturn(
183
                ['name' => 'dir/.foo', 'size' => 10],
184
                ['name' => 'dir/foo', 'size' => 10],
185
                ['name' => 'dir/foo.ext', 'size' => 12],
186
                ['name' => 'dir/bar/foo.ext', 'size' => 13],
187
                ['name' => 'dir/bar/anotherdir', 'size' => 13],
188
                ['name' => 'dir/anotherdir', 'size' => 13],
189
                ['name' => 'dir/_foo', 'size' => 3],
190
                ['name' => 'dir/_fooz/bar', 'size' => 3],
191
                ['name' => 'dir/filename', 'size' => 3],
192
                ['name' => 'dir/okfile', 'size' => 3],
193
                ['name' => 'dir/subdir/file', 'size' => 3],
194
                ['name' => 'dir/zzdir/subdir/file', 'size' => 3]
195
            );
196
        $filterZipFiles = $this->getMethod('Bowerphp\Installer\Installer', 'filterZipFiles');
197
        $ignore = ['**/.*', '_*', 'subdir', '/anotherdir', 'filename', '*.ext'];
198
        $expect = [
199
            'dir/foo',
200
            'dir/bar/anotherdir',
201
            'dir/okfile',
202
            'dir/zzdir/subdir/file',
203
        ];
204
        $this->assertEquals($expect, $filterZipFiles->invokeArgs($this->installer, [$archive, $ignore]));
205
    }
206
207
    public function testUninstall()
208
    {
209
        $package = Mockery::mock('Bowerphp\Package\PackageInterface');
210
211
        $package
212
            ->shouldReceive('getName')->andReturn('jquery');
213
214
        $this->filesystem
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Mockery\Expectation>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
215
            ->shouldReceive('exists')->with(getcwd() . '/bower_components/jquery/.bower.json')->andReturn(true)
216
            ->shouldReceive('remove')->with(getcwd() . '/bower_components/jquery');
217
218
        $this->installer->uninstall($package);
219
    }
220
221
    public function testGetInstalled()
222
    {
223
        $finder = Mockery::mock('Symfony\Component\Finder\Finder');
224
225
        $finder
226
            ->shouldReceive('directories->in')->andReturn(['package1', 'package2']);
227
228
        $this->filesystem
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Mockery\Expectation>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
229
            ->shouldReceive('exists')->with(getcwd() . '/bower_components')->andReturn(true)
230
            ->shouldReceive('exists')->with('package1/.bower.json')->andReturn(true)
231
            ->shouldReceive('exists')->with('package2/.bower.json')->andReturn(true)
232
            ->shouldReceive('read')->with('package1/.bower.json')->andReturn('{"name":"package1","version":"1.0.0"}')
233
            ->shouldReceive('read')->with('package2/.bower.json')->andReturn('{"name":"package2","version":"1.2.3"}');
234
235
        $this->assertCount(2, $this->installer->getInstalled($finder));
236
    }
237
238
    public function testGetInstalledWithoutInstalledPackages()
239
    {
240
        $finder = Mockery::mock('Symfony\Component\Finder\Finder');
241
242
        $this->filesystem
243
            ->shouldReceive('exists')->with(getcwd() . '/bower_components')->andReturn(false);
244
245
        $this->assertEquals([], $this->installer->getInstalled($finder));
246
    }
247
248
    /**
249
     * @expectedException        \RuntimeException
250
     * @expectedExceptionMessage Invalid content in .bower.json for package package1.
251
     */
252
    public function testGetInstalledWithoutBowerJsonFile()
253
    {
254
        $finder = Mockery::mock('Symfony\Component\Finder\Finder');
255
256
        $finder
257
            ->shouldReceive('directories->in')->andReturn(['package1']);
258
259
        $this->filesystem
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Mockery\Expectation>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
260
            ->shouldReceive('exists')->with(getcwd() . '/bower_components')->andReturn(true)
261
            ->shouldReceive('exists')->with('package1/.bower.json')->andReturn(true)
262
            ->shouldReceive('read')->with('package1/.bower.json')->andReturn(null);
263
264
        $this->installer->getInstalled($finder);
265
    }
266
267
    public function testFindDependentPackages()
268
    {
269
        $package = Mockery::mock('Bowerphp\Package\PackageInterface');
270
        $finder = Mockery::mock('Symfony\Component\Finder\Finder');
271
272
        $package
273
            ->shouldReceive('getName')->andReturn('jquery')
274
        ;
275
276
        $finder
277
            ->shouldReceive('directories->in')->andReturn(['package1', 'package2']);
278
279
        $this->filesystem
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Mockery\Expectation>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
280
            ->shouldReceive('exists')->with(getcwd() . '/bower_components')->andReturn(true)
281
            ->shouldReceive('exists')->with('package1/.bower.json')->andReturn(true)
282
            ->shouldReceive('exists')->with('package2/.bower.json')->andReturn(true)
283
            ->shouldReceive('read')->with('package1/.bower.json')->andReturn('{"name":"package1","version":"1.0.0","dependencies":{"jquery": ">=1.3.2"}}')
284
            ->shouldReceive('read')->with('package2/.bower.json')->andReturn('{"name":"package2","version":"1.2.3","dependencies":{"jquery": ">=1.6"}}')
285
        ;
286
287
        $packages = $this->installer->findDependentPackages($package, $finder);
288
289
        $this->assertCount(2, $packages);
290
        $this->assertArrayHasKey('>=1.3.2', $packages);
291
        $this->assertArrayHasKey('>=1.6', $packages);
292
    }
293
294
    /**
295
     * @dataProvider providerIgnored
296
     */
297
    public function testIsIgnored($filename)
298
    {
299
        $ignore = [
300
            '**/.*',
301
            '_*',
302
            'docs-assets',
303
            'examples',
304
            '/fonts',
305
            '/fontsWithSlash/',
306
            'js/tests',
307
            'CNAME',
308
            'CONTRIBUTING.md',
309
            'Gruntfile.js',
310
            'browserstack.json',
311
            'composer.json',
312
            'package.json',
313
            '*.html',
314
        ];
315
316
        $ignored = $this->installer->isIgnored($filename, $ignore, [], 'twbs-bootstrap-6d03173/');
317
        $this->assertTrue($ignored);
318
    }
319
320
    /**
321
     * @dataProvider providerNotIgnored
322
     */
323
    public function testIsNotIgnored($filename)
324
    {
325
        $ignore = [
326
            '**/.*',
327
            '_*',
328
            'docs-assets',
329
            'examples',
330
            '/fonts',
331
            'js/tests',
332
            'CNAME',
333
            'CONTRIBUTING.md',
334
            'Gruntfile.js',
335
            'browserstack.json',
336
            'bower.json',
337
            'composer.json',
338
            'package.json',
339
            '*.html',
340
        ];
341
        $force = [
342
            'bower.json',
343
        ];
344
345
        $ignored = $this->installer->isIgnored($filename, $ignore, $force, 'twbs-bootstrap-6d03173/');
346
        $this->assertFalse($ignored);
347
    }
348
349
    public function providerIgnored()
350
    {
351
        return [
352
            ['twbs-bootstrap-6d03173/.editorconfig'],
353
            ['twbs-bootstrap-6d03173/.gitattributes'],
354
            ['twbs-bootstrap-6d03173/.gitignore'],
355
            ['twbs-bootstrap-6d03173/.travis.yml'],
356
            ['twbs-bootstrap-6d03173/CNAME'],
357
            ['twbs-bootstrap-6d03173/CONTRIBUTING.md'],
358
            ['twbs-bootstrap-6d03173/Gruntfile.js'],
359
            ['twbs-bootstrap-6d03173/_config.yml'],
360
            ['twbs-bootstrap-6d03173/_includes/ads.html'],
361
            ['twbs-bootstrap-6d03173/_includes/footer.html'],
362
            ['twbs-bootstrap-6d03173/_includes/header.html'],
363
            ['twbs-bootstrap-6d03173/_includes/nav-about.html'],
364
            ['twbs-bootstrap-6d03173/_includes/nav-components.html'],
365
            ['twbs-bootstrap-6d03173/_includes/nav-css.html'],
366
            ['twbs-bootstrap-6d03173/_includes/nav-customize.html'],
367
            ['twbs-bootstrap-6d03173/_includes/nav-getting-started.html'],
368
            ['twbs-bootstrap-6d03173/_includes/nav-javascript.html'],
369
            ['twbs-bootstrap-6d03173/_includes/nav-main.html'],
370
            ['twbs-bootstrap-6d03173/_includes/old-bs-docs.html'],
371
            ['twbs-bootstrap-6d03173/_includes/social-buttons.html'],
372
            ['twbs-bootstrap-6d03173/_layouts/default.html'],
373
            ['twbs-bootstrap-6d03173/_layouts/home.html'],
374
            ['twbs-bootstrap-6d03173/about.html'],
375
            ['twbs-bootstrap-6d03173/components.html'],
376
            ['twbs-bootstrap-6d03173/composer.json'],
377
            ['twbs-bootstrap-6d03173/css.html'],
378
            ['twbs-bootstrap-6d03173/customize.html'],
379
            ['twbs-bootstrap-6d03173/docs-assets/css/docs.css'],
380
            ['twbs-bootstrap-6d03173/docs-assets/css/pygments-manni.css'],
381
            ['twbs-bootstrap-6d03173/docs-assets/ico/apple-touch-icon-144-precomposed.png'],
382
            ['twbs-bootstrap-6d03173/docs-assets/ico/favicon.png'],
383
            ['twbs-bootstrap-6d03173/docs-assets/js/application.js'],
384
            ['twbs-bootstrap-6d03173/docs-assets/js/customizer.js'],
385
            ['twbs-bootstrap-6d03173/docs-assets/js/filesaver.js'],
386
            ['twbs-bootstrap-6d03173/docs-assets/js/holder.js'],
387
            ['twbs-bootstrap-6d03173/docs-assets/js/ie8-responsive-file-warning.js'],
388
            ['twbs-bootstrap-6d03173/docs-assets/js/jszip.js'],
389
            ['twbs-bootstrap-6d03173/docs-assets/js/less.js'],
390
            ['twbs-bootstrap-6d03173/docs-assets/js/raw-files.js'],
391
            ['twbs-bootstrap-6d03173/docs-assets/js/uglify.js'],
392
            ['twbs-bootstrap-6d03173/examples/carousel/carousel.css'],
393
            ['twbs-bootstrap-6d03173/examples/carousel/index.html'],
394
            ['twbs-bootstrap-6d03173/examples/grid/grid.css'],
395
            ['twbs-bootstrap-6d03173/examples/grid/index.html'],
396
            ['twbs-bootstrap-6d03173/examples/jumbotron-narrow/index.html'],
397
            ['twbs-bootstrap-6d03173/examples/jumbotron-narrow/jumbotron-narrow.css'],
398
            ['twbs-bootstrap-6d03173/examples/jumbotron/index.html'],
399
            ['twbs-bootstrap-6d03173/examples/jumbotron/jumbotron.css'],
400
            ['twbs-bootstrap-6d03173/examples/justified-nav/index.html'],
401
            ['twbs-bootstrap-6d03173/examples/justified-nav/justified-nav.css'],
402
            ['twbs-bootstrap-6d03173/examples/navbar-fixed-top/index.html'],
403
            ['twbs-bootstrap-6d03173/examples/navbar-fixed-top/navbar-fixed-top.css'],
404
            ['twbs-bootstrap-6d03173/examples/navbar-static-top/index.html'],
405
            ['twbs-bootstrap-6d03173/examples/navbar-static-top/navbar-static-top.css'],
406
            ['twbs-bootstrap-6d03173/examples/navbar/index.html'],
407
            ['twbs-bootstrap-6d03173/examples/navbar/navbar.css'],
408
            ['twbs-bootstrap-6d03173/examples/non-responsive/index.html'],
409
            ['twbs-bootstrap-6d03173/examples/non-responsive/non-responsive.css'],
410
            ['twbs-bootstrap-6d03173/examples/offcanvas/index.html'],
411
            ['twbs-bootstrap-6d03173/examples/offcanvas/offcanvas.css'],
412
            ['twbs-bootstrap-6d03173/examples/offcanvas/offcanvas.js'],
413
            ['twbs-bootstrap-6d03173/examples/screenshots/carousel.jpg'],
414
            ['twbs-bootstrap-6d03173/examples/screenshots/grid.jpg'],
415
            ['twbs-bootstrap-6d03173/examples/screenshots/jumbotron-narrow.jpg'],
416
            ['twbs-bootstrap-6d03173/examples/screenshots/jumbotron.jpg'],
417
            ['twbs-bootstrap-6d03173/examples/screenshots/justified-nav.jpg'],
418
            ['twbs-bootstrap-6d03173/examples/screenshots/navbar-fixed.jpg'],
419
            ['twbs-bootstrap-6d03173/examples/screenshots/navbar-static.jpg'],
420
            ['twbs-bootstrap-6d03173/examples/screenshots/navbar.jpg'],
421
            ['twbs-bootstrap-6d03173/examples/screenshots/non-responsive.jpg'],
422
            ['twbs-bootstrap-6d03173/examples/screenshots/offcanvas.jpg'],
423
            ['twbs-bootstrap-6d03173/examples/screenshots/sign-in.jpg'],
424
            ['twbs-bootstrap-6d03173/examples/screenshots/starter-template.jpg'],
425
            ['twbs-bootstrap-6d03173/examples/screenshots/sticky-footer-navbar.jpg'],
426
            ['twbs-bootstrap-6d03173/examples/screenshots/sticky-footer.jpg'],
427
            ['twbs-bootstrap-6d03173/examples/screenshots/theme.jpg'],
428
            ['twbs-bootstrap-6d03173/examples/signin/index.html'],
429
            ['twbs-bootstrap-6d03173/examples/signin/signin.css'],
430
            ['twbs-bootstrap-6d03173/examples/starter-template/index.html'],
431
            ['twbs-bootstrap-6d03173/examples/starter-template/starter-template.css'],
432
            ['twbs-bootstrap-6d03173/examples/sticky-footer-navbar/index.html'],
433
            ['twbs-bootstrap-6d03173/examples/sticky-footer-navbar/sticky-footer-navbar.css'],
434
            ['twbs-bootstrap-6d03173/examples/sticky-footer/index.html'],
435
            ['twbs-bootstrap-6d03173/examples/sticky-footer/sticky-footer.css'],
436
            ['twbs-bootstrap-6d03173/examples/theme/index.html'],
437
            ['twbs-bootstrap-6d03173/examples/theme/theme.css'],
438
            ['twbs-bootstrap-6d03173/fonts/glyphicons-halflings-regular.eot'],
439
            ['twbs-bootstrap-6d03173/fonts/glyphicons-halflings-regular.svg'],
440
            ['twbs-bootstrap-6d03173/fonts/glyphicons-halflings-regular.ttf'],
441
            ['twbs-bootstrap-6d03173/fonts/glyphicons-halflings-regular.woff'],
442
            ['twbs-bootstrap-6d03173/getting-started.html'],
443
            ['twbs-bootstrap-6d03173/index.html'],
444
            ['twbs-bootstrap-6d03173/javascript.html'],
445
            ['twbs-bootstrap-6d03173/js/.jshintrc'],
446
            ['twbs-bootstrap-6d03173/js/tests/index.html'],
447
            ['twbs-bootstrap-6d03173/js/tests/unit/affix.js'],
448
            ['twbs-bootstrap-6d03173/js/tests/unit/alert.js'],
449
            ['twbs-bootstrap-6d03173/js/tests/unit/button.js'],
450
            ['twbs-bootstrap-6d03173/js/tests/unit/carousel.js'],
451
            ['twbs-bootstrap-6d03173/js/tests/unit/collapse.js'],
452
            ['twbs-bootstrap-6d03173/js/tests/unit/dropdown.js'],
453
            ['twbs-bootstrap-6d03173/js/tests/unit/modal.js'],
454
            ['twbs-bootstrap-6d03173/js/tests/unit/phantom.js'],
455
            ['twbs-bootstrap-6d03173/js/tests/unit/popover.js'],
456
            ['twbs-bootstrap-6d03173/js/tests/unit/scrollspy.js'],
457
            ['twbs-bootstrap-6d03173/js/tests/unit/tab.js'],
458
            ['twbs-bootstrap-6d03173/js/tests/unit/tooltip.js'],
459
            ['twbs-bootstrap-6d03173/js/tests/unit/transition.js'],
460
            ['twbs-bootstrap-6d03173/js/tests/vendor/jquery.js'],
461
            ['twbs-bootstrap-6d03173/js/tests/vendor/qunit.css'],
462
            ['twbs-bootstrap-6d03173/js/tests/vendor/qunit.js'],
463
            ['twbs-bootstrap-6d03173/package.json'],
464
        ];
465
    }
466
467
    public function providerNotIgnored()
468
    {
469
        return [
470
            ['twbs-bootstrap-6d03173/DOCS-LICENSE'],
471
            ['twbs-bootstrap-6d03173/LICENSE'],
472
            ['twbs-bootstrap-6d03173/LICENSE-MIT'],
473
            ['twbs-bootstrap-6d03173/README.md'],
474
            ['twbs-bootstrap-6d03173/bower.json'],
475
            ['twbs-bootstrap-6d03173/dist/css/bootstrap-theme.css'],
476
            ['twbs-bootstrap-6d03173/dist/css/bootstrap-theme.min.css'],
477
            ['twbs-bootstrap-6d03173/dist/css/bootstrap.css'],
478
            ['twbs-bootstrap-6d03173/dist/css/bootstrap.min.css'],
479
            ['twbs-bootstrap-6d03173/dist/fonts/glyphicons-halflings-regular.eot'],
480
            ['twbs-bootstrap-6d03173/dist/fonts/glyphicons-halflings-regular.svg'],
481
            ['twbs-bootstrap-6d03173/dist/fonts/glyphicons-halflings-regular.ttf'],
482
            ['twbs-bootstrap-6d03173/dist/fonts/glyphicons-halflings-regular.woff'],
483
            ['twbs-bootstrap-6d03173/dist/js/bootstrap.js'],
484
            ['twbs-bootstrap-6d03173/dist/js/bootstrap.min.js'],
485
            ['twbs-bootstrap-6d03173/js/affix.js'],
486
            ['twbs-bootstrap-6d03173/js/alert.js'],
487
            ['twbs-bootstrap-6d03173/js/button.js'],
488
            ['twbs-bootstrap-6d03173/js/carousel.js'],
489
            ['twbs-bootstrap-6d03173/js/collapse.js'],
490
            ['twbs-bootstrap-6d03173/js/dropdown.js'],
491
            ['twbs-bootstrap-6d03173/js/modal.js'],
492
            ['twbs-bootstrap-6d03173/js/popover.js'],
493
            ['twbs-bootstrap-6d03173/js/scrollspy.js'],
494
            ['twbs-bootstrap-6d03173/js/tab.js'],
495
            ['twbs-bootstrap-6d03173/js/tooltip.js'],
496
            ['twbs-bootstrap-6d03173/js/transition.js'],
497
            ['twbs-bootstrap-6d03173/less/alerts.less'],
498
            ['twbs-bootstrap-6d03173/less/badges.less'],
499
            ['twbs-bootstrap-6d03173/less/bootstrap.less'],
500
            ['twbs-bootstrap-6d03173/less/breadcrumbs.less'],
501
            ['twbs-bootstrap-6d03173/less/button-groups.less'],
502
            ['twbs-bootstrap-6d03173/less/buttons.less'],
503
            ['twbs-bootstrap-6d03173/less/carousel.less'],
504
            ['twbs-bootstrap-6d03173/less/close.less'],
505
            ['twbs-bootstrap-6d03173/less/code.less'],
506
            ['twbs-bootstrap-6d03173/less/component-animations.less'],
507
            ['twbs-bootstrap-6d03173/less/dropdowns.less'],
508
            ['twbs-bootstrap-6d03173/less/forms.less'],
509
            ['twbs-bootstrap-6d03173/less/glyphicons.less'],
510
            ['twbs-bootstrap-6d03173/less/grid.less'],
511
            ['twbs-bootstrap-6d03173/less/input-groups.less'],
512
            ['twbs-bootstrap-6d03173/less/jumbotron.less'],
513
            ['twbs-bootstrap-6d03173/less/labels.less'],
514
            ['twbs-bootstrap-6d03173/less/list-group.less'],
515
            ['twbs-bootstrap-6d03173/less/media.less'],
516
            ['twbs-bootstrap-6d03173/less/mixins.less'],
517
            ['twbs-bootstrap-6d03173/less/modals.less'],
518
            ['twbs-bootstrap-6d03173/less/navbar.less'],
519
            ['twbs-bootstrap-6d03173/less/navs.less'],
520
            ['twbs-bootstrap-6d03173/less/normalize.less'],
521
            ['twbs-bootstrap-6d03173/less/pager.less'],
522
            ['twbs-bootstrap-6d03173/less/pagination.less'],
523
            ['twbs-bootstrap-6d03173/less/panels.less'],
524
            ['twbs-bootstrap-6d03173/less/popovers.less'],
525
            ['twbs-bootstrap-6d03173/less/print.less'],
526
            ['twbs-bootstrap-6d03173/less/progress-bars.less'],
527
            ['twbs-bootstrap-6d03173/less/responsive-utilities.less'],
528
            ['twbs-bootstrap-6d03173/less/scaffolding.less'],
529
            ['twbs-bootstrap-6d03173/less/tables.less'],
530
            ['twbs-bootstrap-6d03173/less/theme.less'],
531
            ['twbs-bootstrap-6d03173/less/thumbnails.less'],
532
            ['twbs-bootstrap-6d03173/less/tooltip.less'],
533
            ['twbs-bootstrap-6d03173/less/type.less'],
534
            ['twbs-bootstrap-6d03173/less/utilities.less'],
535
            ['twbs-bootstrap-6d03173/less/variables.less'],
536
            ['twbs-bootstrap-6d03173/less/wells.less'],
537
        ];
538
    }
539
540
    public function providerIgnoreExceptions()
541
    {
542
        return [
543
            ['zeroclipboard-zeroclipboard-1ec7da6/test/shared/private.tests.js.html', true],
544
            ['zeroclipboard-zeroclipboard-1ec7da6/src/meta/composer.json.tmpl', true],
545
            ['zeroclipboard-zeroclipboard-1ec7da6/dist/ZeroClipboard.swf', false],
546
            ['zeroclipboard-zeroclipboard-1ec7da6/bower.json', false],
547
        ];
548
    }
549
550
    /**
551
     * @dataProvider providerIgnoreExceptions
552
     */
553
    public function testIgnoreExceptions($file, $shouldIgnore)
554
    {
555
        $ignore = [
556
            '*',
557
            '!/bower.json',
558
            '!/dist/**',
559
        ];
560
        $ignored = $this->installer->isIgnored($file, $ignore, [], 'zeroclipboard-zeroclipboard-1ec7da6/');
561
        $this->assertEquals($ignored, $shouldIgnore);
562
    }
563
564
    public function providerIgnoreAllExceptNegations()
565
    {
566
        return [
567
            ['pippo/src/foo.js', true],
568
            ['pippo/dist/.htaccess', false],
569
            ['pippo/bower.json', true],
570
        ];
571
    }
572
573
    /**
574
     * See issue https://github.com/Bee-Lab/bowerphp/issues/126
575
     *
576
     * @dataProvider providerIgnoreAllExceptNegations
577
     */
578
    public function testIgnoreAllExceptNegations($file, $shouldIgnore)
579
    {
580
        $ignore = [
581
            '**/*',
582
            '!/dist/**',
583
        ];
584
        $ignored = $this->installer->isIgnored($file, $ignore, [], 'pippo/');
585
        $this->assertEquals($ignored, $shouldIgnore);
586
    }
587
}
588