/** * @test */ public function smoke() { $offset_field_parser = $this->getMock('PhpNamedTimeOffset\\OffsetFieldParser'); $offset_field_parser->expects($this->any())->method('toSeconds')->will($this->returnValue(111)); $parser = new YmlConfigParser(new Parser(), $offset_field_parser); $yml = <<<YML offsets: - id: 2070001 name: Pacific Daylight Time short: PDT offset: -7 - id: 2080000 name: Pacific Standard Time short: PST offset: -8 YML; $expected_config = array(2070001 => array('name' => 'Pacific Daylight Time', 'abbreviation' => 'PDT', 'offset' => 111), 2080000 => array('name' => 'Pacific Standard Time', 'abbreviation' => 'PST', 'offset' => 111)); $config = $parser->parse($yml); $this->assertEquals($expected_config, $config); }
protected function execute(InputInterface $input, OutputInterface $output) { $yml = file_get_contents($input->getArgument(self::ARG_SOURCE)); $configs = $this->_parser->parse($yml); $var_export = var_export($configs, true); $timestamp = gmdate('Y-m-d H:i:s e'); $md5_source = md5($yml); $php_config = <<<PHP <?php /** * DO NOT MODIFY * This file is generated by the {$this->getName()} command * * Generated at: {$timestamp} * MD5 of source: {$md5_source} */ return {$var_export}; PHP; $target_path = $input->getArgument(self::ARG_TARGET); file_put_contents($target_path, $php_config); $output->writeln('Wrote configuration to file ' . $target_path); }