Вход Регистрация
Файл: gapps/vendor/nikic/php-parser/test/PhpParser/Builder/TraitTest.php
Строк: 31
<?php

namespace PhpParserBuilder;

use 
PhpParserComment;
use 
PhpParserNode;
use 
PhpParserNodeName;
use 
PhpParserNodeStmt;

class 
TraitTest extends PHPUnit_Framework_TestCase
{
    protected function 
createTraitBuilder($class) {
        return new 
Trait_($class);
    }

    public function 
testStmtAddition() {
        
$method1 = new StmtClassMethod('test1');
        
$method2 = new StmtClassMethod('test2');
        
$method3 = new StmtClassMethod('test3');
        
$prop = new StmtProperty(StmtClass_::MODIFIER_PUBLIC, array(
            new 
StmtPropertyProperty('test')
        ));
        
$trait $this->createTraitBuilder('TestTrait')
            ->
setDocComment('/** Nice trait */')
            ->
addStmt($method1)
            ->
addStmts(array($method2$method3))
            ->
addStmt($prop)
            ->
getNode();
        
$this->assertEquals(new StmtTrait_('TestTrait', array(
            
$prop$method1$method2$method3
        
), array(
            
'comments' => array(
                new 
CommentDoc('/** Nice trait */')
            )
        )), 
$trait);
    }

    
/**
     * @expectedException LogicException
     * @expectedExceptionMessage Unexpected node of type "Stmt_Echo"
     */
    
public function testInvalidStmtError() {
        
$this->createTraitBuilder('Test')
            ->
addStmt(new StmtEcho_(array()))
        ;
    }
}
Онлайн: 0
Реклама