/**
  * @covers \Magento\Tools\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector::parse
  */
 public function testParse()
 {
     $file = __DIR__ . '/_files/objectsCode.php.txt';
     $this->phraseCollector->setIncludeObjects();
     $this->phraseCollector->parse($file);
     $expectation = [['phrase' => '\'Testing\'', 'arguments' => 0, 'file' => $file, 'line' => 3], ['phrase' => '\'More testing\'', 'arguments' => 0, 'file' => $file, 'line' => 4]];
     $this->assertEquals($expectation, $this->phraseCollector->getPhrases());
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 protected function _parse()
 {
     $this->_phraseCollector->setIncludeObjects();
     $this->_phraseCollector->parse($this->_file);
     foreach ($this->_phraseCollector->getPhrases() as $phrase) {
         $this->_addPhrase($phrase['phrase'], $phrase['line']);
     }
 }
 /**
  * @covers \Magento\Tools\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector::parse
  *
  * @param string $file
  * @param array $isEndOfLoopReturnValues
  * @param array $getNextRealTokenReturnValues
  * @param array $getFunctionArgumentsTokensReturnValues
  * @param array $isMatchingClassReturnValues
  * @param array $result
  * @dataProvider testParseDataProvider
  */
 public function testParse($file, array $isEndOfLoopReturnValues, array $getNextRealTokenReturnValues, array $getFunctionArgumentsTokensReturnValues, array $isMatchingClassReturnValues, array $result)
 {
     $matchingClass = 'Phrase';
     $this->tokenizerMock->expects($this->once())->method('parse')->with($file);
     $this->tokenizerMock->expects($this->atLeastOnce())->method('isEndOfLoop')->will(call_user_func_array([$this, 'onConsecutiveCalls'], $isEndOfLoopReturnValues));
     $this->tokenizerMock->expects($this->any())->method('getNextRealToken')->will(call_user_func_array([$this, 'onConsecutiveCalls'], $getNextRealTokenReturnValues));
     $this->tokenizerMock->expects($this->any())->method('getFunctionArgumentsTokens')->will(call_user_func_array([$this, 'onConsecutiveCalls'], $getFunctionArgumentsTokensReturnValues));
     $this->tokenizerMock->expects($this->any())->method('isMatchingClass')->with($matchingClass)->will(call_user_func_array([$this, 'onConsecutiveCalls'], $isMatchingClassReturnValues));
     $this->phraseCollector->setIncludeObjects();
     $this->phraseCollector->parse($file);
     $this->assertEquals($result, $this->phraseCollector->getPhrases());
 }