Ejemplo n.º 1
0
 /**
  * @test
  * @covers Cocur\Ea\MethodFactory::generate()
  * @covers Cocur\Ea\MethodFactory::generateBody()
  */
 public function generateReturnsCodeOfMethodWithBody()
 {
     $m = new MethodFactory('foo');
     $m->setBody('echo "TEST";');
     $this->assertSame('function foo() { echo "TEST"; }', $m->generate());
 }
Ejemplo n.º 2
0
    /**
     * @test
     * @covers Cocur\Ea\ClassFactory::generate()
     * @covers Cocur\Ea\ClassFactory::generateMethods()
     */
    public function generateReturnsSourceCodeOfClassWithMethods()
    {
        $expected = <<<EOF
class Foobar {
    function foo() { echo "TEST"; }
}
EOF;
        $m = new MethodFactory('foo');
        $m->setBody('echo "TEST";');
        $c = new ClassFactory('Foobar');
        $c->addMethod($m);
        $this->assertSame($expected, $c->generate());
    }