Yaffs site version 1.1
[yaffs-website] / vendor / drush / drush / tests / makeTest.php
1 <?php
2
3 namespace Unish;
4
5 /**
6  * Make makefile tests.
7  * @group make
8  * @group slow
9  */
10 class makeMakefileCase extends CommandUnishTestCase {
11   /**
12    * Path to test make files.
13    */
14   protected $makefile_path;
15
16   /**
17    * Initialize $makefile_path.
18    */
19   function __construct() {
20     $this->makefile_path =  dirname(__FILE__) . DIRECTORY_SEPARATOR . 'makefiles';
21   }
22
23   /**
24    * Run a given makefile test.
25    *
26    * @param $test
27    *   The test makefile to run, as defined by $this->getMakefile();
28    */
29   private function runMakefileTest($test) {
30     $default_options = array(
31       'test' => NULL,
32       'md5' => 'print',
33     );
34     $config = $this->getMakefile($test);
35     $options = array_merge($config['options'], $default_options);
36     $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
37     $return = !empty($config['fail']) ? self::EXIT_ERROR : self::EXIT_SUCCESS;
38     $this->drush('make', array($makefile), $options, NULL, NULL, $return);
39
40     // Check the log for the build hash if this test should pass.
41     if (empty($config['fail'])) {
42       $output = $this->getOutput();
43       $this->assertContains($config['md5'], $output, $config['name'] . ' - build md5 matches expected value: ' . $config['md5']);
44     }
45   }
46
47   function getMakefile($key) {
48     static $tests;
49     $tests = $this->listMakefileTests();
50     return $tests[$key];
51   }
52
53   function listMakefileTests() {
54     $tests = array(
55       'bzr' => array(
56         'name'     => 'Bzr',
57         'makefile' => 'bzr.make',
58         'build'    => TRUE,
59         'md5' => '272e2b9bb27794c54396f2f03c159725',
60         'options'  => array(),
61       ),
62       'bz2' => array(
63         'name'     => 'bzip2',
64         'makefile' => 'bz2.make',
65         'build'    => TRUE,
66         'md5'      => '5ec081203131a1a3277c8b23f9ddb995',
67         'options'  => array('no-core' => NULL),
68       ),
69       'bz2-singlefile' => array(
70         'name'     => 'bzip2 single file',
71         'makefile' => 'bz2-singlefile.make',
72         'build'    => TRUE,
73         'md5'      => '4f9d57f6caaf6ece0526d867327621cc',
74         'options'  => array('no-core' => NULL),
75       ),
76       'contrib-destination' => array(
77         'name'     => 'Contrib-destination attribute',
78         'makefile' => 'contrib-destination.make',
79         'build'    => TRUE,
80         'md5' => '2aed36201ede1849ce43d9b7d6f7e9e1',
81         'options'  => array('no-core' => NULL, 'contrib-destination' => '.'),
82       ),
83       'defaults' => array(
84         'name'     => 'Test defaults array.',
85         'makefile' => 'defaults.make',
86         'build'    => TRUE,
87         'md5' => 'e6c0d6b37cd8573cbd188742b95a274e',
88         'options'  => array('no-core' => NULL, 'contrib-destination' => '.'),
89       ),
90       'file' => array(
91         'name'     => 'File extraction',
92         'makefile' => 'file.make',
93         'build'    => TRUE,
94         'md5' => '4e9883d6f9f6572af287635689c2545d',
95         'options'  => array('no-core' => NULL),
96       ),
97       'file-extract' => array(
98         'name'     => 'Extract archives',
99         'makefile' => 'file-extract.make',
100         'build'    => TRUE,
101         'md5' => 'b43d271ab3510eb33c1e300c78893458',
102         // @todo This test often fails with concurrency set to more than one.
103         'options'  => array('no-core' => NULL, 'concurrency' => 1),
104       ),
105       'get' => array(
106         'name'     => 'Test GET retrieval of projects',
107         'makefile' => 'get.make',
108         'build'    => TRUE,
109         'md5' => '4bf18507da89bed601548210c22a3bed',
110         'options'  => array('no-core' => NULL),
111       ),
112       'git' => array(
113         'name'     => 'GIT integration',
114         'makefile' => 'git.make',
115         'build'    => TRUE,
116         'md5' => '4c80d78b50c89b5ba11a997bafec2b43',
117         'options'  => array('no-core' => NULL, 'no-gitinfofile' => NULL),
118       ),
119       'git-simple' => array(
120         'name' => 'Simple git integration',
121         'makefile' => 'git-simple.make',
122         'build' => TRUE,
123         'md5' => '0147681209adef163a8ac2c0cff2a07e',
124         'options'  => array('no-core' => NULL, 'no-gitinfofile' => NULL),
125       ),
126       'git-simple-8' => array(
127         'name' => 'Simple git integration for D8',
128         'makefile' => 'git-simple-8.make',
129         'build' => TRUE,
130         'options'  => array('no-core' => NULL),
131       ),
132       'gzip' => array(
133         'name'     => 'gzip',
134         'makefile' => 'gzip.make',
135         'build'    => TRUE,
136         'md5'      => '25b514df18a87b655437388af083e22c',
137         'options'  => array('no-core' => NULL),
138       ),
139       'ignore-checksums' => array(
140         'name'     => 'Ignore invalid checksum/s',
141         'makefile' => 'md5-fail.make',
142         'build'    => TRUE,
143         'md5' => 'f76ec174a775ce67f8e9edcb02336ef2',
144         'options'  => array('no-core' => NULL, 'ignore-checksums' => NULL),
145       ),
146       'include' => array(
147         'name'     => 'Including files and property overrides',
148         'makefile' => 'include.make',
149         'build'    => TRUE,
150         'md5' => 'e2e230ec5eccaf5618050559ab11510d',
151         'options'  => array(),
152       ),
153       'includes-git' => array(
154         'name'     => 'Including makefiles from remote repositories',
155         'makefile' => 'includes-main.make',
156         'build'    => TRUE,
157         'options'  => array(),
158       ),
159       'limit-libraries' => array(
160         'name'     => 'Limit libraries downloaded',
161         'makefile' => 'limited-projects-libraries.make',
162         'build'    => TRUE,
163         'md5' => 'cb0da4465d86eb34cafb167787862eb6',
164         'options'  => array('no-core' => NULL, 'libraries' => 'drush_make'),
165       ),
166       'limit-libraries-multiple' => array(
167         'name'     => 'Limit multiple libraries downloaded',
168         'makefile' => 'limited-projects-libraries.make',
169         'build'    => TRUE,
170         'md5' => '7c10e6fc65728a77a2b0aed4ec2a29cd',
171         'options'  => array('no-core' => NULL, 'libraries' => 'drush_make,token'),
172       ),
173       'limit-projects' => array(
174         'name'     => 'Limit projects downloaded',
175         'makefile' => 'limited-projects-libraries.make',
176         'build'    => TRUE,
177         'md5' => '3149650120e541d7d0fa577eef0ee9a3',
178         'options'  => array('no-core' => NULL, 'projects' => 'boxes'),
179       ),
180       'limit-projects-multiple' => array(
181         'name'     => 'Limit multiple projects downloaded',
182         'makefile' => 'limited-projects-libraries.make',
183         'build'    => TRUE,
184         'md5' => 'ef8996c4d6c6f0d229e2237c73860071',
185         'options'  => array('no-core' => NULL, 'projects' => 'boxes,admin_menu'),
186       ),
187       'md5-fail' => array(
188         'name'     => 'Failed MD5 validation test',
189         'makefile' => 'md5-fail.make',
190         'build'    => FALSE,
191         'md5' => FALSE,
192         'options'  => array('no-core' => NULL),
193         'fail' => TRUE,
194       ),
195       'md5-succeed' => array(
196         'name'     => 'MD5 validation',
197         'makefile' => 'md5-succeed.make',
198         'build'    => TRUE,
199         'md5' => 'f76ec174a775ce67f8e9edcb02336ef2',
200         'options'  => array('no-core' => NULL),
201       ),
202       'no-patch-txt' => array(
203         'name'     => 'Test --no-patch-txt option',
204         'makefile' => 'patches.make',
205         'build'    => TRUE,
206         'md5' => '59267a04f98374ed5b0b75e90cefcd9c',
207         'options'  => array('no-core' => NULL, 'no-patch-txt' => NULL),
208       ),
209       'options-array' => array(
210         'name'     => 'Test global options array',
211         'makefile' => 'options-array.make',
212         'build'    => TRUE,
213         'options'  => array(),
214       ),
215       'options-project' => array(
216         'name'     => 'Test per-project options array',
217         'makefile' => 'options-project.make',
218         'build'    => TRUE,
219         'options'  => array(),
220       ),
221       'patch' => array(
222         'name'     => 'Test patching and writing of PATCHES.txt file',
223         'makefile' => 'patches.make',
224         'build'    => TRUE,
225         'md5' => '536ee287344c24f47e0808622d7d091b',
226         'options'  => array('no-core' => NULL),
227       ),
228       'recursion' => array(
229         'name'     => 'Recursion',
230         'makefile' => 'recursion.make',
231         'build'    => TRUE,
232         'md5' => 'cd095bd6dadb2f0d3e81f85f13685372',
233         'options'  => array(
234           'no-core' => NULL,
235           'contrib-destination' => 'profiles/drupal_forum',
236         ),
237       ),
238       'recursion-override' => array(
239         'name' => 'Recursion overrides',
240         'makefile' => 'recursion-override.make',
241         'build' => TRUE,
242         'md5' => 'a13c3d5d416be9fa78569514844b96a2',
243         'options' => array(
244           'no-core' => NULL,
245         ),
246       ),
247       'subtree' => array(
248         'name'     => 'Use subtree from downloaded archive',
249         'makefile' => 'subtree.make',
250         'build'    => TRUE,
251         'md5' => 'db3770d8b4c9ce77510cbbcc566da9b8',
252         'options'  => array('no-core' => NULL),
253       ),
254       'svn' => array(
255         'name'     => 'SVN',
256         'makefile' => 'svn.make',
257         'build'    => TRUE,
258         'md5' => '0cb28a15958d7fc4bbf8bf6b00bc6514',
259         'options'  => array('no-core' => NULL),
260       ),
261       'translations' => array(
262         'name'     => 'Translation downloads',
263         'makefile' => 'translations.make',
264         'options'  => array(
265           'translations' => 'es,pt-br',
266           'no-core' => NULL,
267         ),
268       ),
269       'translations-inside' => array(
270         'name'     => 'Translation downloads inside makefile',
271         'makefile' => 'translations-inside.make',
272       ),
273       'translations-inside7' => array(
274         'name'     => 'Translation downloads inside makefile, core 7.x',
275         'makefile' => 'translations-inside7.make',
276       ),
277       'use-distribution-as-core' => array(
278         'name'     => 'Use distribution as core',
279         'makefile' => 'use-distribution-as-core.make',
280         'build'    => TRUE,
281         'md5' => '643a603025a20d498eb583a1e7970bad',
282         'options'  => array(),
283       ),
284     );
285     // Replicate ini tests for YAML format.
286     foreach ($tests as $id => $test) {
287       $id_yaml = $id  . '-yaml';
288       $tests[$id_yaml] = $test;
289       $tests[$id_yaml]['name'] = $tests[$id]['name'] . '(in YAML format)';
290       $tests[$id_yaml]['makefile'] = $tests[$id]['makefile'] . '.yml';
291     }
292     return $tests;
293   }
294
295   /************************************************************************
296    *                                                                      *
297    *  List of make tests (in alphabetical order, for easier navigation.)  *
298    *                                                                      *
299    ************************************************************************/
300
301   /**
302    * Test .info file writing and the use of a git reference cache for
303    * git downloads.
304    */
305   function testInfoFileWritingGit() {
306     // Use the git-simple.make file.
307     $config = $this->getMakefile('git-simple');
308
309     $options = array('no-core' => NULL);
310     $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
311     $this->drush('make', array($makefile, UNISH_SANDBOX . '/test-build'), $options);
312
313     // Test cck_signup.info file.
314     $this->assertFileExists(UNISH_SANDBOX . '/test-build/sites/all/modules/cck_signup/cck_signup.info');
315     $contents = file_get_contents(UNISH_SANDBOX . '/test-build/sites/all/modules/cck_signup/cck_signup.info');
316     $this->assertContains('; Information added by drush on 2011-07-27', $contents);
317     $this->assertContains('version = "2fe932c"', $contents);
318     $this->assertContains('project = "cck_signup"', $contents);
319
320     // Verify that a reference cache was created.
321     $cache_dir = UNISH_CACHE . DIRECTORY_SEPARATOR . 'cache';
322     $this->assertFileExists($cache_dir . '/git/cck_signup-' . md5('http://git.drupal.org/project/cck_signup.git'));
323
324     // Test context_admin.info file.
325     $this->assertFileExists(UNISH_SANDBOX . '/test-build/sites/all/modules/context_admin/context_admin.info');
326     $contents = file_get_contents(UNISH_SANDBOX . '/test-build/sites/all/modules/context_admin/context_admin.info');
327     $this->assertContains('; Information added by drush on 2011-10-27', $contents);
328     $this->assertContains('version = "eb9f05e"', $contents);
329     $this->assertContains('project = "context_admin"', $contents);
330
331     // Verify git reference cache exists.
332     $this->assertFileExists($cache_dir . '/git/context_admin-' . md5('http://git.drupal.org/project/context_admin.git'));
333
334     // Text caption_filter .info rewrite.
335     $this->assertFileExists(UNISH_SANDBOX . '/test-build/sites/all/modules/contrib/caption_filter/caption_filter.info');
336     $contents = file_get_contents(UNISH_SANDBOX . '/test-build/sites/all/modules/contrib/caption_filter/caption_filter.info');
337     $this->assertContains('; Information added by drush on 2011-09-20', $contents);
338     $this->assertContains('version = "7.x-1.2+0-dev"', $contents);
339     $this->assertContains('project = "caption_filter"', $contents);
340   }
341
342   /**
343    * Test .info file writing and the use of a git reference cache for
344    * git downloads.
345    */
346   function testInfoYamlFileWritingGit() {
347     // Use the Drupal 8 .make file.
348     $config = $this->getMakefile('git-simple-8');
349
350     $options = array('no-core' => NULL);
351     $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
352     $this->drush('make', array($makefile, UNISH_SANDBOX . '/test-build'), $options);
353
354     $this->assertFileExists(UNISH_SANDBOX . '/test-build/modules/honeypot/honeypot.info.yml');
355     $contents = file_get_contents(UNISH_SANDBOX . '/test-build/modules/honeypot/honeypot.info.yml');
356     $this->assertContains('# Information added by drush on 2015-09-03', $contents);
357     $this->assertContains("version: '8.x-1.x-dev'", $contents);
358     $this->assertContains("project: 'honeypot'", $contents);
359   }
360
361   function testMakeBzr() {
362     // Silently skip bzr test if bzr is not installed.
363     exec('which bzr', $output, $whichBzrErrorCode);
364     if (!$whichBzrErrorCode) {
365       $this->runMakefileTest('bzr');
366     }
367     else {
368       $this->markTestSkipped('bzr command is not available.');
369     }
370   }
371
372   function testMakeBZ2() {
373     // Silently skip bz2 test if bz2 is not installed.
374     exec('which bzip2', $output, $whichBzip2ErrorCode);
375     if (!$whichBzip2ErrorCode) {
376       $this->runMakefileTest('bz2');
377     }
378     else {
379       $this->markTestSkipped('bzip2 command not available.');
380     }
381   }
382
383   /* TODO: http://download.gna.org/wkhtmltopdf/obsolete/linux/wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2 cannot be downloaded any longer
384   function testMakeBZ2SingleFile() {
385     // Silently skip bz2 test if bz2 is not installed.
386     exec('which bzip2', $output, $whichBzip2ErrorCode);
387     if (!$whichBzip2ErrorCode) {
388       $this->runMakefileTest('bz2-singlefile');
389     }
390     else {
391       $this->markTestSkipped('bzip2 command not available.');
392     }
393   }
394   */
395
396   function testMakeContribDestination() {
397     $this->runMakefileTest('contrib-destination');
398   }
399
400   /** @group make.yml */
401   function testMakeContribDestinationYaml() {
402     $this->runMakefileTest('contrib-destination-yaml');
403   }
404
405   function testMakeDefaults() {
406     $this->runMakefileTest('defaults');
407   }
408
409   /** @group make.yml */
410   function testMakeDefaultsYaml() {
411     $this->runMakefileTest('defaults-yaml');
412   }
413
414   function testMakeFile() {
415     $this->runMakefileTest('file');
416   }
417
418   function testMakeFileExtract() {
419     // Silently skip file extraction test if unzip is not installed.
420     exec('which unzip', $output, $whichUnzipErrorCode);
421     if (!$whichUnzipErrorCode) {
422       $this->runMakefileTest('file-extract');
423     }
424     else {
425       $this->markTestSkipped('unzip command not available.');
426     }
427   }
428
429   function testMakeGet() {
430     $this->runMakefileTest('get');
431   }
432
433   function testMakeGit() {
434     $this->runMakefileTest('git');
435   }
436
437   function testMakeGitSimple() {
438     $this->runMakefileTest('git-simple');
439   }
440
441   function testMakeGZip() {
442     // Silently skip gzip test if either gzip or unzip is not installed.
443     exec('which gzip', $output, $whichGzipErrorCode);
444     if (!$whichGzipErrorCode) {
445       exec('which unzip', $output, $whichUnzipErrorCode);
446       if (!$whichUnzipErrorCode) {
447         $this->runMakefileTest('gzip');
448       }
449       else {
450         $this->markTestSkipped('unzip command not available.');
451       }
452     }
453     else {
454       $this->markTestSkipped('gzip command not available.');
455     }
456   }
457
458   function testMakeIgnoreChecksums() {
459     $this->runMakefileTest('ignore-checksums');
460   }
461
462   function testMakeInclude() {
463     $this->runMakefileTest('include');
464   }
465
466   /** @group make.yml */
467   function testMakeIncludeYaml() {
468     $this->runMakefileTest('include-yaml');
469   }
470
471   /**
472    * Test git support on includes directive.
473    */
474   function testMakeIncludesGit() {
475     $config = $this->getMakefile('includes-git');
476     $options = array();
477     $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
478     $this->drush('make', array($makefile, UNISH_SANDBOX . '/test-git-includes'), $options);
479
480     // Verify that core and example main module were downloaded.
481     $this->assertFileExists(UNISH_SANDBOX . '/test-git-includes/README.txt');
482     $this->assertFileExists(UNISH_SANDBOX . '/test-git-includes/sites/all/modules/contrib/apachesolr/README.txt');
483
484     // Verify that module included in sub platform was downloaded.
485     $this->assertFileExists(UNISH_SANDBOX . '/test-git-includes/sites/all/modules/contrib/jquery_update/README.txt');
486   }
487
488   function testMakeLimitProjects() {
489     $this->runMakefileTest('limit-projects');
490     $this->runMakefileTest('limit-projects-multiple');
491   }
492
493   function testMakeLimitLibraries() {
494     $this->runMakefileTest('limit-libraries');
495     $this->runMakefileTest('limit-libraries-multiple');
496   }
497
498
499   function testMakeMd5Fail() {
500     $this->runMakefileTest('md5-fail');
501   }
502
503   function testMakeMd5Succeed() {
504     $this->runMakefileTest('md5-succeed');
505   }
506
507   /**
508    * Test that make_move_build() doesn't wipe out directories that it shouldn't.
509    */
510   function testMakeMoveBuild() {
511     // Manually download a module.
512     $options = array(
513       'default-major' => 6, // The makefile used below is core = "6.x".
514       'destination' => UNISH_SANDBOX . '/sites/all/modules/contrib',
515       'yes' => NULL,
516       'dev' => NULL,
517     );
518     $this->drush('pm-download', array('cck_signup'), $options);
519
520     // Build a make file.
521     $config = $this->getMakefile('contrib-destination');
522     $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
523     $this->drush('make', array($makefile, '.'), $config['options']);
524
525     // Verify that the manually downloaded module still exists.
526     $this->assertFileExists(UNISH_SANDBOX . '/sites/all/modules/contrib/cck_signup/README.txt');
527   }
528
529   function testMakeNoPatchTxt() {
530     $this->runMakefileTest('no-patch-txt');
531   }
532
533   function testMakeNoRecursion() {
534     $config = $this->getMakefile('recursion');
535     $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
536
537     $install_directory = UNISH_SANDBOX . DIRECTORY_SEPARATOR . 'norecursion';
538     $this->drush('make', array('--no-core', '--no-recursion', $makefile, $install_directory));
539     $this->assertNotContains("ctools", $this->getOutput(), "Make with --no-recursion does not recurse into drupal_forum to download ctools.");
540   }
541
542   /**
543    * Test no-core and working-copy in options array.
544    */
545   function testMakeOptionsArray() {
546     // Use the goptions-array.make file.
547     $config = $this->getMakefile('options-array');
548
549     $makefile_path = dirname(__FILE__) . '/makefiles';
550     $makefile = $makefile_path . '/' . $config['makefile'];
551     $install_directory = UNISH_SANDBOX . '/options-array';
552     $this->drush('make', array($makefile, $install_directory));
553
554     // Test cck_signup .git/HEAD file.
555     $this->assertFileExists($install_directory . '/sites/all/modules/cck_signup/.git/HEAD');
556     $contents = file_get_contents($install_directory . '/sites/all/modules/cck_signup/.git/HEAD');
557     $this->assertContains('2fe932c', $contents);
558
559     // Test context_admin .git/HEAD file.
560     $this->assertFileExists($install_directory . '/sites/all/modules/context_admin/.git/HEAD');
561     $contents = file_get_contents($install_directory . '/sites/all/modules/context_admin/.git/HEAD');
562     $this->assertContains('eb9f05e', $contents);
563   }
564
565   /**
566    * Test per project working-copy option.
567    */
568   function testMakeOptionsProject() {
569     // Use the options-project.make file.
570     $config = $this->getMakefile('options-project');
571
572     $makefile_path = dirname(__FILE__) . '/makefiles';
573     $options = array('no-core' => NULL);
574     $makefile = $makefile_path . '/' . $config['makefile'];
575     $install_directory = UNISH_SANDBOX . '/options-project';
576     $this->drush('make', array($makefile, $install_directory), $options);
577
578     // Test context_admin .git/HEAD file.
579     $this->assertFileExists($install_directory . '/sites/all/modules/context_admin/.git/HEAD');
580     $contents = file_get_contents($install_directory . '/sites/all/modules/context_admin/.git/HEAD');
581     $this->assertContains('eb9f05e', $contents);
582
583     // Test cck_signup .git/HEAD file does not exist.
584     $this->assertFileNotExists($install_directory . '/sites/all/modules/cck_signup/.git/HEAD');
585
586     // Test caption_filter .git/HEAD file.
587     $this->assertFileExists($install_directory . '/sites/all/modules/contrib/caption_filter/.git/HEAD');
588     $contents = file_get_contents($install_directory . '/sites/all/modules/contrib//caption_filter/.git/HEAD');
589     $this->assertContains('c9794cf', $contents);
590   }
591
592   function testMakePatch() {
593     $this->runMakefileTest('patch');
594   }
595
596   function testMakeRecursion() {
597     $this->runMakefileTest('recursion');
598   }
599
600   function testMakeRecursionOverride() {
601     // @todo This is skipped for now since the test relies on sourceforge.
602     // It can be replaced if a suitable module that installs projects (not
603     // libraries, which aren't properly overridable).
604     $this->markTestSkipped('skipping recursion-override test');
605     return;
606
607     // Silently skip file extraction test if unzip is not installed.
608     exec('which unzip', $output, $whichUnzipErrorCode);
609     if (!$whichUnzipErrorCode) {
610       $this->runMakefileTest('recursion-override');
611     }
612     else {
613       $this->markTestSkipped('unzip command not available.');
614     }
615   }
616
617   function testMakeSubtree() {
618     // Silently skip subtree test if unzip is not installed.
619     exec('which unzip', $output, $whichUnzipErrorCode);
620     if (!$whichUnzipErrorCode) {
621       $config = $this->getMakefile('subtree');
622
623       $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
624       $install_directory = UNISH_SANDBOX . DIRECTORY_SEPARATOR . 'subtree';
625       $this->drush('make', array('--no-core', $makefile, $install_directory));
626
627       $files['nivo-slider'] = array(
628         'exists' => array(
629           'jquery.nivo.slider.js',
630           'jquery.nivo.slider.pack.js',
631           'license.txt',
632           'nivo-slider.css',
633           'README',
634         ),
635         'notexists' => array(
636           '__MACOSX',
637           'nivo-slider',
638         ),
639       );
640       $files['fullcalendar'] = array(
641         'exists' => array(
642           'fullcalendar.css',
643           'fullcalendar.js',
644           'fullcalendar.min.js',
645           'fullcalendar.print.css',
646           'gcal.js',
647         ),
648         'notexists' => array(
649           'changelog.txt',
650           'demos',
651           'fullcalendar',
652           'GPL-LICENSE.txt',
653           'jquery',
654           'MIT-LICENSE.txt',
655         ),
656       );
657       $basedir = $install_directory . DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . 'all' . DIRECTORY_SEPARATOR . 'libraries';
658       foreach ($files as $lib => $details) {
659         $dir =  $basedir . DIRECTORY_SEPARATOR . $lib;
660         if (!empty($details['exists'])) {
661           foreach ($details['exists'] as $file) {
662             $this->assertFileExists($dir . DIRECTORY_SEPARATOR . $file);
663           }
664         }
665
666         if (!empty($details['notexists'])) {
667           foreach ($details['notexists'] as $file) {
668             $this->assertFileNotExists($dir . DIRECTORY_SEPARATOR . $file);
669           }
670         }
671       }
672     }
673     else {
674       $this->markTestSkipped('unzip command not available.');
675     }
676   }
677
678   function testMakeSvn() {
679     return $this->markTestSkipped('svn support is deprecated.');
680     // Silently skip svn test if svn is not installed.
681     exec('which svn', $output, $whichSvnErrorCode);
682     if (!$whichSvnErrorCode) {
683       $this->runMakefileTest('svn');
684     }
685     else {
686       $this->markTestSkipped('svn command not available.');
687     }
688   }
689
690   /**
691    * Translations can change arbitrarily, so these test for the existence of .po
692    * files, rather than trying to match a build hash.
693    */
694   function testMakeTranslations() {
695     $config = $this->getMakefile('translations');
696
697     $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
698     $install_directory = UNISH_SANDBOX . '/translations';
699     $this->drush('make', array($makefile, $install_directory), $config['options']);
700
701     $po_files = array(
702       'sites/all/modules/token/translations/pt-br.po',
703       'sites/all/modules/token/translations/es.po',
704     );
705
706     foreach ($po_files as $po_file) {
707       $this->assertFileExists($install_directory . '/' . $po_file);
708     }
709   }
710
711   /**
712    * Translations can change arbitrarily, so these test for the existence of .po
713    * files, rather than trying to match a build hash.
714    */
715   function testMakeTranslationsInside() {
716     $config = $this->getMakefile('translations-inside');
717
718     $makefile = $this->makefile_path . '/' . $config['makefile'];
719     $install_directory = UNISH_SANDBOX . '/translations-inside';
720     $this->drush('make', array($makefile, $install_directory));
721
722     $po_files = array(
723       'profiles/default/translations/pt-br.po',
724       'profiles/default/translations/es.po',
725       'sites/all/modules/token/translations/pt-br.po',
726       'sites/all/modules/token/translations/es.po',
727       'modules/system/translations/pt-br.po',
728       'modules/system/translations/es.po',
729     );
730
731     foreach ($po_files as $po_file) {
732       $this->assertFileExists($install_directory . '/' . $po_file);
733     }
734   }
735
736   /**
737    * Translations can change arbitrarily, so these test for the existence of .po
738    * files, rather than trying to match a build hash.
739    */
740   function testMakeTranslationsInside7() {
741     $config = $this->getMakefile('translations-inside7');
742
743     $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
744     $install_directory = UNISH_SANDBOX . '/translations-inside7';
745     $this->drush('make', array($makefile, $install_directory));
746
747     $po_files = array(
748       'profiles/minimal/translations/pt-br.po',
749       'profiles/minimal/translations/es.po',
750       'profiles/testing/translations/pt-br.po',
751       'profiles/testing/translations/es.po',
752       'profiles/standard/translations/pt-br.po',
753       'profiles/standard/translations/es.po',
754       'sites/all/modules/token/translations/pt-br.po',
755       'sites/all/modules/token/translations/es.po',
756       'modules/system/translations/pt-br.po',
757       'modules/system/translations/es.po',
758     );
759
760     foreach ($po_files as $po_file) {
761       $this->assertFileExists($install_directory . '/' . $po_file);
762     }
763   }
764
765   /**
766    * Test that a distribution can be used as a "core" project.
767    */
768   function testMakeUseDistributionAsCore() {
769     $this->runMakefileTest('use-distribution-as-core');
770   }
771
772   /**
773    * Test that files without a core attribute are correctly identified.
774    */
775   public function testNoCoreMakefileParsing() {
776     require_once __DIR__ . '/../commands/make/make.utilities.inc';
777
778     // INI.
779     $data = file_get_contents(__DIR__ . '/makefiles/no-core.make');
780     $parsed = _make_determine_format($data);
781     $this->assertEquals('ini', $parsed['format']);
782     $this->assertEquals(42, $parsed['projects']['foo']['version']);
783
784     // YAML.
785     $data = file_get_contents(__DIR__ . '/makefiles/no-core.make.yml');
786     $parsed = _make_determine_format($data);
787     $this->assertEquals('yaml', $parsed['format']);
788     $this->assertEquals(42, $parsed['projects']['foo']['version']);
789   }
790
791 }