/** @dataProvider getMessagesExtractionTestData */ public function testMessagesExtraction(\Twig_Node $node, array $expectedMessages) { $env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); $visitor = new TranslationNodeVisitor(); $visitor->enable(); $visitor->enterNode($node, $env); $visitor->leaveNode($node, $env); $this->assertEquals($expectedMessages, $visitor->getMessages()); }
/** @dataProvider getDefaultDomainAssignmentTestData */ public function testNewModuleWithoutDefaultDomainTag(\Twig_Node $node) { $env = new \Twig_Environment(new \Twig_Loader_String(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); $visitor = new TranslationDefaultDomainNodeVisitor(); // visit trans_default_domain tag $newModule = TwigNodeProvider::getModule('test'); $visitor->enterNode($newModule, $env); $visitor->leaveNode($newModule, $env); // visit tested node $enteredNode = $visitor->enterNode($node, $env); $leavedNode = $visitor->leaveNode($node, $env); $this->assertSame($node, $enteredNode); $this->assertSame($node, $leavedNode); // extracting tested node messages $visitor = new TranslationNodeVisitor(); $visitor->enable(); $visitor->enterNode($node, $env); $visitor->leaveNode($node, $env); $this->assertEquals(array(array(self::$message, null)), $visitor->getMessages()); }