gossi\codegen\tests\model\AbstractPhpStructTest::testUseStatements PHP Method

testUseStatements() public method

public testUseStatements ( )
    public function testUseStatements()
    {
        $class = new PhpClass();
        $this->assertTrue($class->getUseStatements()->isEmpty());
        $this->assertSame($class, $class->setUseStatements(['foo' => 'bar']));
        $this->assertEquals(['foo' => 'bar'], $class->getUseStatements()->toArray());
        $this->assertSame($class, $class->addUseStatement('Foo\\Bar'));
        $this->assertEquals(['foo' => 'bar', 'Bar' => 'Foo\\Bar'], $class->getUseStatements()->toArray());
        $this->assertSame($class, $class->addUseStatement('Foo\\Bar', 'Baz'));
        $this->assertEquals(['foo' => 'bar', 'Bar' => 'Foo\\Bar', 'Baz' => 'Foo\\Bar'], $class->getUseStatements()->toArray());
        $this->assertTrue($class->hasUseStatement('bar'));
        $class->removeUseStatement('bar');
        $this->assertFalse($class->hasUseStatement('bar'));
        $class->clearUseStatements();
        $class->addUseStatement('ArrayList');
        $this->assertEquals(['ArrayList' => 'ArrayList'], $class->getUseStatements()->toArray());
        // declareUse
        $this->assertEquals('ArrayList', $class->declareUse('phootwork\\collection\\ArrayList'));
        $this->assertEquals('Foo', $class->declareUse('phootwork\\collection\\Stack', 'Foo'));
        $class->declareUses('phootwork\\collection\\Set', 'phootwork\\collection\\Map');
        $this->assertTrue($class->hasUseStatement('phootwork\\collection\\Set'));
        $this->assertTrue($class->hasUseStatement('phootwork\\collection\\Map'));
    }