Yaffs site version 1.1
[yaffs-website] / vendor / drush / drush / tests / lockMakeTest.php
1 <?php
2
3 namespace Unish;
4
5 /**
6  * Make makefile tests.
7  * @group make
8  * @group slow
9  */
10 class lockMakefileCase 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 runLockfileTest($test) {
30     $default_options = array(
31       'result-file' => UNISH_SANDBOX . '/test.lock.yml',
32     );
33     $config = $this->getLockfile($test);
34     $options = array_merge($config['options'], $default_options);
35     $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
36     $lockfile = $this->makefile_path . DIRECTORY_SEPARATOR . 'lockfiles' . DIRECTORY_SEPARATOR . $config['lockfile'];
37     $this->drush('make-lock', array($makefile), $options);
38     $expected = trim(file_get_contents($lockfile));
39     $actual = trim(file_get_contents($options['result-file']));
40
41     $this->assertEquals($expected, $actual);
42   }
43
44   function getLockfile($key) {
45     static $tests;
46     $tests = $this->listLockfileTests();
47     return $tests[$key];
48   }
49
50   function listLockfileTests() {
51     $tests = array(
52       'default' => array(
53         'name'     => 'lock',
54         'makefile' => 'lock-default.make.yml',
55         'lockfile' => 'default.lock.yml',
56         'options'  => array(),
57       ),
58       'git' => array(
59         'name'     => 'git',
60         'makefile' => 'lock-git.make.yml',
61         'lockfile' => 'git.lock.yml',
62         'options'  => array(),
63       ),
64     );
65     return $tests;
66   }
67
68   /************************************************************************
69    *                                                                      *
70    *  List of lock tests (in alphabetical order, for easier navigation.)  *
71    *                                                                      *
72    ************************************************************************/
73
74   /**
75    * Test locking basic version data.
76    */
77   function testDefaultLock() {
78     $this->runLockfileTest('default');
79   }
80
81   /**
82    * Test locking git version data.
83    */
84   function testGitLock() {
85     $this->runLockfileTest('git');
86   }
87
88 }