Completed
Push — master ( 3d3abc...41dbe6 )
by Pavel
39:01 queued 29:15
created
tests/FileHandlerTest.php 1 patch
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -9,148 +9,148 @@
 block discarded – undo
9 9
 
10 10
 class FileHandlerTest extends \PHPUnit_Framework_TestCase {
11 11
 
12
-	/**
13
-	 * @var FileHandler
14
-	 */
15
-	private $fileHandler;
16
-
17
-	protected function setUp() {
18
-		parent::setUp();
19
-		$fs = new Filesystem();
20
-		$this->fileHandler = new FileHandler($fs, array('--env=prod'));
21
-	}
22
-
23
-	/**
24
-	 * @dataProvider preparePathProvider
25
-	 * @param $path
26
-	 * @param $expected
27
-	 */
28
-	public function testPreparePath($path, $expected) {
29
-		$this->assertEquals($expected, $this->fileHandler->preparePath($path));
30
-	}
31
-
32
-	public function preparePathProvider() {
33
-		return array(
34
-			'without env parameter' => array(
35
-				'path' => 'folder/parameters.yml',
36
-				'expected' => 'folder/parameters.yml'
37
-			),
38
-			'with env parameter' => array(
39
-				'path' => '{env}/parameters.yml',
40
-				'expected' => 'prod/parameters.yml'
41
-			),
42
-			'with different parameter' => array(
43
-				'path' => '{enev}/parameters.yml',
44
-				'expected' => '{enev}/parameters.yml'
45
-			)
46
-		);
47
-	}
48
-
49
-	/**
50
-	 * @param $name
51
-	 * @param $expected
52
-	 *
53
-	 * @dataProvider argumentValueProvider
54
-	 */
55
-	public function testArgumentValue($name, $expected) {
56
-		$this->assertEquals($expected, $this->fileHandler->getArgumentValue($name));
57
-	}
58
-
59
-	public function argumentValueProvider() {
60
-		return array(
61
-			'env found' => array(
62
-				'name' => 'env',
63
-				'expected' => 'prod',
64
-			),
65
-			'--env not found' => array(
66
-				'name' => '--env',
67
-				'expected' => false,
68
-			)
69
-		);
70
-	}
71
-
72
-
73
-	/**
74
-	 * @param $currentPath
75
-	 * @param $importPath
76
-	 * @param $expected
77
-	 * @dataProvider resolvePathProvider
78
-	 */
79
-	public function testResolvePath($currentPath, $importPath, $expected) {
80
-		$this->assertEquals($expected, $this->fileHandler->resolvePath($currentPath, $importPath));
81
-	}
82
-
83
-	public function resolvePathProvider() {
84
-		return array(
85
-			'parent path' => array(
86
-				'currentPath' => '/home/user/dir/current.yml',
87
-				'importPath' => '../import.yml',
88
-				'expected' => '/home/user/dir/../import.yml',
89
-			),
90
-			'current path' => array(
91
-				'currentPath' => '/home/user/dir/current.yml',
92
-				'importPath' => './import.yml',
93
-				'expected' => '/home/user/dir/./import.yml',
94
-			),
95
-
96
-			'current simple path' => array(
97
-				'currentPath' => '/home/user/dir/current.yml',
98
-				'importPath' => 'import.yml',
99
-				'expected' => '/home/user/dir/import.yml',
100
-			),
101
-			'absolute path' => array(
102
-				'currentPath' => '/home/user/dir/current.yml',
103
-				'importPath' => '/import.yml',
104
-				'expected' => '/import.yml',
105
-			)
106
-		);
107
-	}
108
-
109
-	public function testInitDirectory() {
110
-		vfsStreamWrapper::register();
111
-		vfsStreamWrapper::setRoot(new vfsStreamDirectory('root'));
112
-
113
-		$buildDirName = 'createthis';
114
-		$buildDir = vfsStream::url('root/' . $buildDirName);
115
-
116
-		//currently doesn't exists
117
-		$this->assertFalse(vfsStreamWrapper::getRoot()->hasChild($buildDirName));
118
-
119
-		//create one
120
-		$this->fileHandler->initDirectory($buildDir);
121
-		$this->assertTrue(vfsStreamWrapper::getRoot()->hasChild($buildDirName));
122
-		vfsStreamWrapper::unregister();
123
-	}
124
-
125
-	/**
126
-	 * @param $expected
127
-	 * @param $value
128
-	 *
129
-	 * @dataProvider testProcessEnvironmentalVariableProvider
130
-	 */
131
-	public function testProcessEnvironmentalVariable($value, $expected) {
132
-		$this->assertEquals($expected, $this->fileHandler->processEnvironmentalVariable($value));
133
-	}
134
-
135
-	public function testProcessEnvironmentalVariableProvider() {
136
-		return array(
137
-			'string' => array(
138
-				'value' => 'string',
139
-				'expected' => 'string'
140
-			),
141
-			'number' => array(
142
-				'value' => 444,
143
-				'expected' => 444
144
-			),
145
-			'env variable' => array(
146
-				'value' => '%env(PATH)%',
147
-				'expected' => getenv('PATH')
148
-			),
149
-
150
-			'string like env' => array(
151
-				'value' => 'env(PATH)%',
152
-				'expected' => 'env(PATH)%'
153
-			)
154
-		);
155
-	}
12
+    /**
13
+     * @var FileHandler
14
+     */
15
+    private $fileHandler;
16
+
17
+    protected function setUp() {
18
+        parent::setUp();
19
+        $fs = new Filesystem();
20
+        $this->fileHandler = new FileHandler($fs, array('--env=prod'));
21
+    }
22
+
23
+    /**
24
+     * @dataProvider preparePathProvider
25
+     * @param $path
26
+     * @param $expected
27
+     */
28
+    public function testPreparePath($path, $expected) {
29
+        $this->assertEquals($expected, $this->fileHandler->preparePath($path));
30
+    }
31
+
32
+    public function preparePathProvider() {
33
+        return array(
34
+            'without env parameter' => array(
35
+                'path' => 'folder/parameters.yml',
36
+                'expected' => 'folder/parameters.yml'
37
+            ),
38
+            'with env parameter' => array(
39
+                'path' => '{env}/parameters.yml',
40
+                'expected' => 'prod/parameters.yml'
41
+            ),
42
+            'with different parameter' => array(
43
+                'path' => '{enev}/parameters.yml',
44
+                'expected' => '{enev}/parameters.yml'
45
+            )
46
+        );
47
+    }
48
+
49
+    /**
50
+     * @param $name
51
+     * @param $expected
52
+     *
53
+     * @dataProvider argumentValueProvider
54
+     */
55
+    public function testArgumentValue($name, $expected) {
56
+        $this->assertEquals($expected, $this->fileHandler->getArgumentValue($name));
57
+    }
58
+
59
+    public function argumentValueProvider() {
60
+        return array(
61
+            'env found' => array(
62
+                'name' => 'env',
63
+                'expected' => 'prod',
64
+            ),
65
+            '--env not found' => array(
66
+                'name' => '--env',
67
+                'expected' => false,
68
+            )
69
+        );
70
+    }
71
+
72
+
73
+    /**
74
+     * @param $currentPath
75
+     * @param $importPath
76
+     * @param $expected
77
+     * @dataProvider resolvePathProvider
78
+     */
79
+    public function testResolvePath($currentPath, $importPath, $expected) {
80
+        $this->assertEquals($expected, $this->fileHandler->resolvePath($currentPath, $importPath));
81
+    }
82
+
83
+    public function resolvePathProvider() {
84
+        return array(
85
+            'parent path' => array(
86
+                'currentPath' => '/home/user/dir/current.yml',
87
+                'importPath' => '../import.yml',
88
+                'expected' => '/home/user/dir/../import.yml',
89
+            ),
90
+            'current path' => array(
91
+                'currentPath' => '/home/user/dir/current.yml',
92
+                'importPath' => './import.yml',
93
+                'expected' => '/home/user/dir/./import.yml',
94
+            ),
95
+
96
+            'current simple path' => array(
97
+                'currentPath' => '/home/user/dir/current.yml',
98
+                'importPath' => 'import.yml',
99
+                'expected' => '/home/user/dir/import.yml',
100
+            ),
101
+            'absolute path' => array(
102
+                'currentPath' => '/home/user/dir/current.yml',
103
+                'importPath' => '/import.yml',
104
+                'expected' => '/import.yml',
105
+            )
106
+        );
107
+    }
108
+
109
+    public function testInitDirectory() {
110
+        vfsStreamWrapper::register();
111
+        vfsStreamWrapper::setRoot(new vfsStreamDirectory('root'));
112
+
113
+        $buildDirName = 'createthis';
114
+        $buildDir = vfsStream::url('root/' . $buildDirName);
115
+
116
+        //currently doesn't exists
117
+        $this->assertFalse(vfsStreamWrapper::getRoot()->hasChild($buildDirName));
118
+
119
+        //create one
120
+        $this->fileHandler->initDirectory($buildDir);
121
+        $this->assertTrue(vfsStreamWrapper::getRoot()->hasChild($buildDirName));
122
+        vfsStreamWrapper::unregister();
123
+    }
124
+
125
+    /**
126
+     * @param $expected
127
+     * @param $value
128
+     *
129
+     * @dataProvider testProcessEnvironmentalVariableProvider
130
+     */
131
+    public function testProcessEnvironmentalVariable($value, $expected) {
132
+        $this->assertEquals($expected, $this->fileHandler->processEnvironmentalVariable($value));
133
+    }
134
+
135
+    public function testProcessEnvironmentalVariableProvider() {
136
+        return array(
137
+            'string' => array(
138
+                'value' => 'string',
139
+                'expected' => 'string'
140
+            ),
141
+            'number' => array(
142
+                'value' => 444,
143
+                'expected' => 444
144
+            ),
145
+            'env variable' => array(
146
+                'value' => '%env(PATH)%',
147
+                'expected' => getenv('PATH')
148
+            ),
149
+
150
+            'string like env' => array(
151
+                'value' => 'env(PATH)%',
152
+                'expected' => 'env(PATH)%'
153
+            )
154
+        );
155
+    }
156 156
 }
Please login to merge, or discard this patch.
tests/Adapter/Output/PHPConstantsOutputAdapterTest.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -8,66 +8,66 @@
 block discarded – undo
8 8
 
9 9
 class PHPConstantsOutputAdapterTest extends \PHPUnit_Framework_TestCase {
10 10
 
11
-	/**
12
-	 * @var PHPConstantsOutputAdapter
13
-	 */
14
-	private $PHPConstantsOutputAdapter;
11
+    /**
12
+     * @var PHPConstantsOutputAdapter
13
+     */
14
+    private $PHPConstantsOutputAdapter;
15 15
 
16
-	protected function setUp() {
17
-		parent::setUp();
18
-		$this->PHPConstantsOutputAdapter = new PHPConstantsOutputAdapter();
19
-	}
16
+    protected function setUp() {
17
+        parent::setUp();
18
+        $this->PHPConstantsOutputAdapter = new PHPConstantsOutputAdapter();
19
+    }
20 20
 
21
-	/**
22
-	 * @param $parameters
23
-	 * @param $fileName
24
-	 * @param $env
25
-	 * @param $expected
26
-	 *
27
-	 * @dataProvider processProvider
28
-	 */
29
-	public function testProcess($parameters, $fileName, $env, $date, $expected) {
30
-		vfsStreamWrapper::register();
31
-		vfsStreamWrapper::setRoot(new vfsStreamDirectory('root'));
21
+    /**
22
+     * @param $parameters
23
+     * @param $fileName
24
+     * @param $env
25
+     * @param $expected
26
+     *
27
+     * @dataProvider processProvider
28
+     */
29
+    public function testProcess($parameters, $fileName, $env, $date, $expected) {
30
+        vfsStreamWrapper::register();
31
+        vfsStreamWrapper::setRoot(new vfsStreamDirectory('root'));
32 32
 
33
-		$fileNameVFS = vfsStream::url('root/' . $fileName);
34
-		$this->PHPConstantsOutputAdapter->process($parameters, $fileNameVFS, $env, $date);
35
-		$actual = file_get_contents(vfsStream::url('root/' . $fileName));
36
-		$this->assertEquals($expected, $actual);
37
-		vfsStreamWrapper::unregister();
38
-	}
33
+        $fileNameVFS = vfsStream::url('root/' . $fileName);
34
+        $this->PHPConstantsOutputAdapter->process($parameters, $fileNameVFS, $env, $date);
35
+        $actual = file_get_contents(vfsStream::url('root/' . $fileName));
36
+        $this->assertEquals($expected, $actual);
37
+        vfsStreamWrapper::unregister();
38
+    }
39 39
 
40
-	public function processProvider() {
41
-		$date = time();
42
-		return array(
43
-			'number' => array(
44
-				'parameters' => array(
45
-					'PARAMETER' => 1100,
46
-					'PARAMETER1' => 1.100
47
-				),
48
-				'fileName' => 'parameters.php',
49
-				'env' => 'devlike/test',
50
-				'date' => $date,
51
-				'expected' => sprintf("%s\n%s\n%s\n",
52
-					sprintf("<?php\n/** This file is auto-generated during the build process of '%s' environment at %s **/", 'devlike/test', date(DATE_ATOM, $date)),
53
-					"define('PARAMETER', 1100);",
54
-					"define('PARAMETER1', 1.1);"
55
-				),
40
+    public function processProvider() {
41
+        $date = time();
42
+        return array(
43
+            'number' => array(
44
+                'parameters' => array(
45
+                    'PARAMETER' => 1100,
46
+                    'PARAMETER1' => 1.100
47
+                ),
48
+                'fileName' => 'parameters.php',
49
+                'env' => 'devlike/test',
50
+                'date' => $date,
51
+                'expected' => sprintf("%s\n%s\n%s\n",
52
+                    sprintf("<?php\n/** This file is auto-generated during the build process of '%s' environment at %s **/", 'devlike/test', date(DATE_ATOM, $date)),
53
+                    "define('PARAMETER', 1100);",
54
+                    "define('PARAMETER1', 1.1);"
55
+                ),
56 56
 
57
-			),
58
-			'array' => array(
59
-				'parameters' => array(
60
-					'PARAMETER' => array(100, 200, 300, "aaa'", array("'\"'"))
61
-				),
62
-				'fileName' => 'parameters.php',
63
-				'env' => 'devlike/test',
64
-				'date' => $date,
65
-				'expected' => sprintf("%s\n%s\n",
66
-					sprintf("<?php\n/** This file is auto-generated during the build process of '%s' environment at %s **/", 'devlike/test', date(DATE_ATOM, $date)),
67
-					sprintf("define('PARAMETER', '%s');", "a:5:{i:0;i:100;i:1;i:200;i:2;i:300;i:3;s:4:\"aaa\\'\";i:4;a:1:{i:0;s:3:\"\\'\"\\'\";}}")
68
-				),
57
+            ),
58
+            'array' => array(
59
+                'parameters' => array(
60
+                    'PARAMETER' => array(100, 200, 300, "aaa'", array("'\"'"))
61
+                ),
62
+                'fileName' => 'parameters.php',
63
+                'env' => 'devlike/test',
64
+                'date' => $date,
65
+                'expected' => sprintf("%s\n%s\n",
66
+                    sprintf("<?php\n/** This file is auto-generated during the build process of '%s' environment at %s **/", 'devlike/test', date(DATE_ATOM, $date)),
67
+                    sprintf("define('PARAMETER', '%s');", "a:5:{i:0;i:100;i:1;i:200;i:2;i:300;i:3;s:4:\"aaa\\'\";i:4;a:1:{i:0;s:3:\"\\'\"\\'\";}}")
68
+                ),
69 69
 
70
-			),
71
-		);
72
-	}
70
+            ),
71
+        );
72
+    }
73 73
 }
Please login to merge, or discard this patch.
src/Adapter/Output/YamlOutputAdapter.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@
 block discarded – undo
24 24
 
25 25
     public function process($parameters, $fileName, $env, $date = null)
26 26
     {
27
-	    if (is_null($date)) {
28
-		    $date = time();
29
-	    }
27
+        if (is_null($date)) {
28
+            $date = time();
29
+        }
30 30
 
31 31
         file_put_contents($fileName, sprintf("# This file is auto-generated during the build process of '%s' environment at %s\n", $env, date(DATE_ATOM, $date)) . Yaml::dump(array($this->parameterKey => $parameters)), 99);
32 32
     }
Please login to merge, or discard this patch.
src/Adapter/Output/OutputAdapterInterface.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@
 block discarded – undo
8 8
      */
9 9
     public static function getName();
10 10
 
11
-	/**
12
-	 * @param $parameters
13
-	 * @param $fileName
14
-	 * @param $env
15
-	 * @param null|int $date
16
-	 * @return
17
-	 */
11
+    /**
12
+     * @param $parameters
13
+     * @param $fileName
14
+     * @param $env
15
+     * @param null|int $date
16
+     * @return
17
+     */
18 18
     public function process($parameters, $fileName, $env, $date = null);
19 19
 }
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
src/Adapter/Output/PHPConstantsOutputAdapter.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@
 block discarded – undo
12 12
 
13 13
     public function process($parameters, $fileName, $env, $date = null)
14 14
     {
15
-    	if (is_null($date)) {
16
-    		$date = time();
17
-	    }
15
+        if (is_null($date)) {
16
+            $date = time();
17
+        }
18 18
 
19 19
         $content = sprintf("<?php\n/** This file is auto-generated during the build process of '%s' environment at %s **/\n", $env, date(DATE_ATOM, $date));
20 20
         foreach ($parameters as $key => $value) {
Please login to merge, or discard this patch.