Exemplo n.º 1
0
 public function test_it_creates_pristine_section()
 {
     $parser = new DeviseParser();
     $traverser = new NodeTraverser();
     $traverser->addVisitor(new CreatePristineSection($parser));
     $nodes = $parser->parse($this->fixture('devise-views.interpret3'));
     $nodes = $traverser->traverse($nodes);
     assertCount(1, $nodes);
     assertInstanceOf('PhpParser\\Node\\Stmt\\If_', $nodes[0]);
 }
Exemplo n.º 2
0
 public function test_it_can_traverse_nodes()
 {
     $parser = new DeviseParser();
     $traverser = new NodeTraverser();
     $traverser->addVisitor(new AddPlaceHolderTags($parser));
     $nodes = $parser->parse($this->fixture('devise-views.interpret3'));
     $nodes = $traverser->traverse($nodes);
     assertCount(4, $nodes);
     assertEquals('<span data-dvs-placeholder="key1" data-dvs-placeholder="key2" data-dvs-placeholder="key3"></span>', $nodes[1]->value);
 }
Exemplo n.º 3
0
 public function test_it_renames_devise_tags()
 {
     $parser = new DeviseParser();
     $traverser = new NodeTraverser();
     $traverser->addVisitor(new RegisterDeviseTags($parser));
     $nodes = $parser->parse($this->fixture('devise-views.interpret3'));
     $nodes = $traverser->traverse($nodes);
     assertContains('<body>', $nodes[9]->value);
     assertInstanceOf('PhpParser\\Node\\Stmt\\Foreach_', $nodes[10]);
     assertContains('<div data-devise-<?php echo devise_tag_cid(\'key1\', "field", null, "key1", "type", "Human name 1", null, null, null, null, null) ?>="key1">Hello there #1</div>', $nodes[10]->stmts[0]->value);
     assertContains('<div data-devise-<?php echo devise_tag_cid(\'key2\', "field", null, "key2", "type", "Human name 2", null, null, null, null, null) ?>="key2">Hello there #2</div>', $nodes[10]->stmts[1]->stmts[0]->value);
     assertContains('<p data-devise-<?php echo devise_tag_cid(\'outside\', "field", null, "outside", "type", "Outside Key", null, null, null, null, null) ?>="outside">', $nodes[11]->value);
 }
Exemplo n.º 4
0
 public function test_it_can_traverse_nodes()
 {
     $parser = new DeviseParser();
     $traverser = new NodeTraverser();
     $traverser->addVisitor(new EchoDeviseMagic($parser));
     $nodes = $parser->parse($this->fixture('devise-views.interpret7'));
     $nodes = $traverser->traverse($nodes);
     assertCount(6, $nodes);
     // dd($nodes[0]);
     assertEquals('dvsmagic', $nodes[0]->exprs[0]->name);
     // dd($nodes[1]);
     assertEquals('dvsmagic', $nodes[1]->exprs[0]->name);
     // dd($nodes[2]);
     assertEquals('dvsmagic', $nodes[2]->exprs[0]->name);
     // dd($nodes[3]);
     assertEquals('dvsmagic', $nodes[3]->exprs[0]->if->name);
     // dd($nodes[4]);
     assertEquals('dvsmagic', $nodes[4]->exprs[0]->left->left->name);
     // dd($nodes[5]);
     assertEquals('dvsmagic', $nodes[5]->exprs[0]->args[0]->value->name);
 }