@@ -8,66 +8,66 @@ |
||
| 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 | } |
@@ -24,9 +24,9 @@ |
||
| 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 | } |
@@ -8,12 +8,12 @@ |
||
| 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 |
@@ -12,9 +12,9 @@ |
||
| 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) { |