/** * @param array $options * @param array $phpFiles * @param array $jsFiles * @param array $phpMap * @param array $jsMap * @param array $expectedResult * @dataProvider addPhraseDataProvider */ public function testAddPhrase($options, $phpFiles, $jsFiles, $phpMap, $jsMap, $expectedResult) { // 1. Create mocks $phpAdapter = new AdapterStub(); $jsAdapter = new AdapterStub(); // 2. Set mocks $this->parser->addAdapter('php', $phpAdapter); $this->parser->addAdapter('js', $jsAdapter); //3. Set fixtures $phpAdapter->setValueMap($phpMap); $jsAdapter->setValueMap($jsMap); $this->factory->expects($this->any())->method('createPhrase')->with()->will($this->returnValueMap([[['phrase' => 'php phrase111', 'translation' => 'php phrase111', 'quote' => "'"], 'php phrase111'], [['phrase' => 'php phrase112', 'translation' => 'php phrase112', 'quote' => '"'], 'php phrase112'], [['phrase' => 'php phrase121', 'translation' => 'php phrase121', 'quote' => "'"], 'php phrase121'], [['phrase' => 'php phrase122', 'translation' => 'php phrase122', 'quote' => '"'], 'php phrase122'], [['phrase' => 'js phrase111', 'translation' => 'js phrase111', 'quote' => "'"], 'js phrase111'], [['phrase' => 'js phrase112', 'translation' => 'js phrase112', 'quote' => '"'], 'js phrase112'], [['phrase' => 'js phrase121', 'translation' => 'js phrase121', 'quote' => "'"], 'js phrase121'], [['phrase' => 'js phrase122', 'translation' => 'js phrase122', 'quote' => '"'], 'js phrase122']])); //4. Set expectations $this->filesCollector->expects($this->any())->method('getFiles')->will($this->returnValueMap([[$options[0]['paths'], '', $phpFiles], [$options[1]['paths'], '', $jsFiles]])); $result = $this->parser->parse($options); $this->assertEquals($expectedResult, $result); }
/** * @param array $options * @param string $message * @dataProvider dataProviderForValidateOptions */ public function testValidateOptions($options, $message) { $this->setExpectedException('InvalidArgumentException', $message); $this->_parserMock->addAdapter('php', $this->getMock('Magento\\Setup\\Module\\I18n\\Parser\\AdapterInterface')); $this->_parserMock->parse($options); }
public function testParse() { $this->_adapterMock->expects($this->once())->method('_parse'); $this->_adapterMock->parse('file1'); }