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

use PhpParserBuilder;
use 
PhpParserNodeName;
use 
PhpParserNodeStmt;

class 
UseTest extends PHPUnit_Framework_TestCase
{
    protected function 
createUseBuilder($name$type StmtUse_::TYPE_NORMAL) {
        return new 
BuilderUse_($name$type);
    }

    public function 
testCreation() {
        
$node $this->createUseBuilder('FooBar')->getNode();
        
$this->assertEquals(new StmtUse_(array(
            new 
StmtUseUse(new Name('FooBar'), 'Bar')
        )), 
$node);

        
$node $this->createUseBuilder(new Name('FooBar'))->as('XYZ')->getNode();
        
$this->assertEquals(new StmtUse_(array(
            new 
StmtUseUse(new Name('FooBar'), 'XYZ')
        )), 
$node);

        
$node $this->createUseBuilder('foobar'StmtUse_::TYPE_FUNCTION)->as('foo')->getNode();
        
$this->assertEquals(new StmtUse_(array(
            new 
StmtUseUse(new Name('foobar'), 'foo')
        ), 
StmtUse_::TYPE_FUNCTION), $node);
    }

    public function 
testNonExistingMethod() {
        
$this->setExpectedException('LogicException''Method "foo" does not exist');
        
$builder $this->createUseBuilder('Test');
        
$builder->foo();
    }
}
Онлайн: 0
Реклама