| @@ 15-67 (lines=53) @@ | ||
| 12 | * |
|
| 13 | * @author Sławomir Kania <[email protected]> |
|
| 14 | */ |
|
| 15 | class InterfaceManagerTest extends BaseManager |
|
| 16 | { |
|
| 17 | ||
| 18 | /** |
|
| 19 | * @var InterfaceManager |
|
| 20 | */ |
|
| 21 | protected $interfaceManager = null; |
|
| 22 | ||
| 23 | /** |
|
| 24 | * SET UP |
|
| 25 | */ |
|
| 26 | public function setUp() |
|
| 27 | { |
|
| 28 | parent::setUp(); |
|
| 29 | $this->interfaceManager = $this->preapareClassManager()->getInterface(); |
|
| 30 | } |
|
| 31 | ||
| 32 | public function testManger() |
|
| 33 | { |
|
| 34 | $this->assertInstanceOf('\HelloWordPl\SimpleEntityGeneratorBundle\Lib\Interfaces\RenderableInterface', $this->interfaceManager); |
|
| 35 | $this->assertInstanceOf('\HelloWordPl\SimpleEntityGeneratorBundle\Lib\Items\InterfaceManager', $this->interfaceManager); |
|
| 36 | $this->assertInstanceOf('\HelloWordPl\SimpleEntityGeneratorBundle\Lib\Interfaces\StructureWithMethodsInterface', $this->interfaceManager); |
|
| 37 | $this->assertInstanceOf('\HelloWordPl\SimpleEntityGeneratorBundle\Lib\Interfaces\DumpableInterface', $this->interfaceManager); |
|
| 38 | $this->assertEquals("Interface for entity : \AppBundle\Entity\User", $this->interfaceManager->getComment()); |
|
| 39 | $this->assertEquals("\AppBundle\Entity\UserInterface", $this->interfaceManager->getNamespace()); |
|
| 40 | $this->assertEquals("UserInterface", $this->interfaceManager->getName()); |
|
| 41 | $this->assertEquals("/AppBundle/Entity", $this->interfaceManager->getDirectory()); |
|
| 42 | $this->assertEquals("\AppBundle\Entity", $this->interfaceManager->getNamespaceWithoutName()); |
|
| 43 | $this->assertEquals("AppBundle\Entity", $this->interfaceManager->getNamespaceWithoutNameAndBackslashPrefix()); |
|
| 44 | } |
|
| 45 | ||
| 46 | public function testValidManagerWhenValid() |
|
| 47 | { |
|
| 48 | $errors = $this->getValidator()->validate($this->interfaceManager); |
|
| 49 | $this->assertEquals(0, $errors->count()); |
|
| 50 | } |
|
| 51 | ||
| 52 | public function testValidManagerWhenEmptyClassManager() |
|
| 53 | { |
|
| 54 | $this->interfaceManager->setClassManager(new ClassManager()); |
|
| 55 | $errors = $this->getValidator()->validate($this->interfaceManager); |
|
| 56 | $this->assertEquals(4, $errors->count()); |
|
| 57 | } |
|
| 58 | ||
| 59 | public function testValidManagerWhenInvalidMethod() |
|
| 60 | { |
|
| 61 | $methods = $this->interfaceManager->getMethods(); |
|
| 62 | $methods->add(new MethodGetterInterfaceManager($this->interfaceManager->getClassManager())); // broken method |
|
| 63 | $this->interfaceManager->setMethods($methods); |
|
| 64 | $errors = $this->getValidator()->validate($this->interfaceManager); |
|
| 65 | $this->assertEquals(1, $errors->count()); |
|
| 66 | } |
|
| 67 | } |
|
| 68 | ||
| @@ 15-67 (lines=53) @@ | ||
| 12 | * |
|
| 13 | * @author Sławomir Kania <[email protected]> |
|
| 14 | */ |
|
| 15 | class TestClassManagerTest extends BaseManager |
|
| 16 | { |
|
| 17 | ||
| 18 | /** |
|
| 19 | * @var TestClassManager |
|
| 20 | */ |
|
| 21 | protected $testClassManager = null; |
|
| 22 | ||
| 23 | /** |
|
| 24 | * SET UP |
|
| 25 | */ |
|
| 26 | public function setUp() |
|
| 27 | { |
|
| 28 | parent::setUp(); |
|
| 29 | $this->testClassManager = $this->preapareClassManager()->getTestClass(); |
|
| 30 | } |
|
| 31 | ||
| 32 | public function testManger() |
|
| 33 | { |
|
| 34 | $this->assertInstanceOf('\HelloWordPl\SimpleEntityGeneratorBundle\Lib\Interfaces\RenderableInterface', $this->testClassManager); |
|
| 35 | $this->assertInstanceOf('\HelloWordPl\SimpleEntityGeneratorBundle\Lib\Interfaces\DumpableInterface', $this->testClassManager); |
|
| 36 | $this->assertInstanceOf('\HelloWordPl\SimpleEntityGeneratorBundle\Lib\Interfaces\StructureWithMethodsInterface', $this->testClassManager); |
|
| 37 | $this->assertInstanceOf('\HelloWordPl\SimpleEntityGeneratorBundle\Lib\Items\TestClassManager', $this->testClassManager); |
|
| 38 | $this->assertEquals('Test for \AppBundle\Entity\User', $this->testClassManager->getComment()); |
|
| 39 | $this->assertEquals('/AppBundle/Tests/Entity', $this->testClassManager->getDirectory()); |
|
| 40 | $this->assertEquals('UserTest', $this->testClassManager->getName()); |
|
| 41 | $this->assertEquals('\AppBundle\Tests\Entity\UserTest', $this->testClassManager->getNamespace()); |
|
| 42 | $this->assertEquals('\AppBundle\Tests\Entity', $this->testClassManager->getNamespaceWithoutName()); |
|
| 43 | $this->assertEquals('AppBundle\Tests\Entity', $this->testClassManager->getNamespaceWithoutNameAndBackslashPrefix()); |
|
| 44 | } |
|
| 45 | ||
| 46 | public function testValidManagerWhenValid() |
|
| 47 | { |
|
| 48 | $errors = $this->getValidator()->validate($this->testClassManager); |
|
| 49 | $this->assertEquals(0, $errors->count()); |
|
| 50 | } |
|
| 51 | ||
| 52 | public function testValidManagerWhenInvalidTestMethod() |
|
| 53 | { |
|
| 54 | $methods = $this->testClassManager->getMethods(); |
|
| 55 | $methods->add(new TestMethodManager()); |
|
| 56 | $this->testClassManager->setMethods($methods); |
|
| 57 | $errors = $this->getValidator()->validate($this->testClassManager); |
|
| 58 | $this->assertEquals(1, $errors->count()); |
|
| 59 | } |
|
| 60 | ||
| 61 | public function testValidManagerWhenInvalidClassManager() |
|
| 62 | { |
|
| 63 | $this->testClassManager->setClassManager(new ClassManager()); |
|
| 64 | $errors = $this->getValidator()->validate($this->testClassManager); |
|
| 65 | $this->assertEquals(3, $errors->count()); |
|
| 66 | } |
|
| 67 | } |
|
| 68 | ||