-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from wimvds/unit-tests
corrected / refactored / added unit tests
- Loading branch information
Showing
8 changed files
with
428 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
parameters: | ||
kunstmaan_redirect.menu.adaptor.class: 'Kunstmaan\RedirectBundle\Helper\Menu\RedirectMenuAdaptor' | ||
kunstmaan_redirect.redirect_repository.class: 'Kunstmaan\RedirectBundle\Repository\RedirectRepository' | ||
kunstmaan_redirect.redirect.class: 'Kunstmaan\RedirectBundle\Entity\Redirect' | ||
|
||
services: | ||
kunstmaan_redirect.menu.adaptor: | ||
class: "%kunstmaan_redirect.menu.adaptor.class%" | ||
tags: | ||
- { name: 'kunstmaan_admin.menu.adaptor' } | ||
|
||
kunstmaan_redirect.repositories.redirect: | ||
class: "%kunstmaan_redirect.redirect_repository.class%" | ||
factory_service: "doctrine.orm.entity_manager" | ||
factory_method: getRepository | ||
arguments: ["%kunstmaan_redirect.redirect.class%"] | ||
|
||
kunstmaan_redirect.redirectrouter: | ||
class: Kunstmaan\RedirectBundle\Router\RedirectRouter | ||
arguments: ["@service_container"] | ||
arguments: ["@kunstmaan_redirect.repositories.redirect"] | ||
tags: | ||
- { name: router, priority: 1 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?php | ||
|
||
namespace Kunstmaan\RedirectBundle\Tests\Entity; | ||
|
||
use Doctrine\ORM\EntityManager; | ||
use Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper; | ||
use Kunstmaan\RedirectBundle\AdminList\RedirectAdminListConfigurator; | ||
|
||
/** | ||
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-04-16 at 18:05:47. | ||
*/ | ||
class RedirectAdminListConfiguratorTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var EntityManager | ||
*/ | ||
protected $em; | ||
|
||
/** | ||
* @var AclHelper | ||
*/ | ||
protected $aclHelper; | ||
|
||
/** | ||
* @var RedirectAdminListConfigurator | ||
*/ | ||
protected $object; | ||
|
||
/** | ||
* Sets up the fixture, for example, opens a network connection. | ||
* This method is called before a test is executed. | ||
*/ | ||
protected function setUp() | ||
{ | ||
$this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager') | ||
->disableOriginalConstructor()->getMock(); | ||
$this->aclHelper = $this->getMockBuilder('Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper') | ||
->disableOriginalConstructor()->getMock(); | ||
|
||
$this->object = new RedirectAdminListConfigurator($this->em, $this->aclHelper); | ||
} | ||
|
||
/** | ||
* Tears down the fixture, for example, closes a network connection. | ||
* This method is called after a test is executed. | ||
*/ | ||
protected function tearDown() | ||
{ | ||
} | ||
|
||
/** | ||
* @covers Kunstmaan\RedirectBundle\AdminList\RedirectAdminListConfigurator::buildFields | ||
*/ | ||
public function testBuildFields() | ||
{ | ||
$this->object->buildFields(); | ||
$fields = $this->object->getFields(); | ||
$this->assertEquals(3, count($fields)); | ||
$fieldNames = array_map( | ||
function ($field) { | ||
return $field->getName(); | ||
}, | ||
$fields | ||
); | ||
$this->assertEquals(array('origin', 'target', 'permanent'), $fieldNames); | ||
} | ||
|
||
/** | ||
* @covers Kunstmaan\RedirectBundle\AdminList\RedirectAdminListConfigurator::buildFilters | ||
*/ | ||
public function testBuildFilters() | ||
{ | ||
$filterBuilder = $this->getMock('Kunstmaan\AdminListBundle\AdminList\FilterBuilder'); | ||
$filterBuilder | ||
->expects($this->at(0)) | ||
->method('add') | ||
->with('origin'); | ||
$filterBuilder | ||
->expects($this->at(1)) | ||
->method('add') | ||
->with('target'); | ||
$filterBuilder | ||
->expects($this->at(2)) | ||
->method('add') | ||
->with('permanent'); | ||
$this->object->setFilterBuilder($filterBuilder); | ||
$this->object->buildFilters(); | ||
} | ||
|
||
/** | ||
* @covers Kunstmaan\RedirectBundle\AdminList\RedirectAdminListConfigurator::getBundleName | ||
*/ | ||
public function testGetBundleName() | ||
{ | ||
$this->assertEquals('KunstmaanRedirectBundle', $this->object->getBundleName()); | ||
} | ||
|
||
/** | ||
* @covers Kunstmaan\RedirectBundle\AdminList\RedirectAdminListConfigurator::getEntityName | ||
*/ | ||
public function testGetEntityName() | ||
{ | ||
$this->assertEquals('Redirect', $this->object->getEntityName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace Kunstmaan\RedirectBundle\Tests\Entity; | ||
|
||
use Kunstmaan\RedirectBundle\Entity\Redirect; | ||
|
||
/** | ||
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-04-16 at 17:26:20. | ||
*/ | ||
class RedirectTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var Redirect | ||
*/ | ||
protected $object; | ||
|
||
/** | ||
* Sets up the fixture, for example, opens a network connection. | ||
* This method is called before a test is executed. | ||
*/ | ||
protected function setUp() | ||
{ | ||
$this->object = new Redirect; | ||
} | ||
|
||
/** | ||
* Tears down the fixture, for example, closes a network connection. | ||
* This method is called after a test is executed. | ||
*/ | ||
protected function tearDown() | ||
{ | ||
} | ||
|
||
/** | ||
* @covers Kunstmaan\RedirectBundle\Entity\Redirect::getOrigin | ||
* @covers Kunstmaan\RedirectBundle\Entity\Redirect::setOrigin | ||
*/ | ||
public function testGetSetOrigin() | ||
{ | ||
$this->object->setOrigin('origin'); | ||
$this->assertEquals('origin', $this->object->getOrigin()); | ||
} | ||
|
||
/** | ||
* @covers Kunstmaan\RedirectBundle\Entity\Redirect::getTarget | ||
* @covers Kunstmaan\RedirectBundle\Entity\Redirect::setTarget | ||
*/ | ||
public function testGetSetTarget() | ||
{ | ||
$this->object->setTarget('target'); | ||
$this->assertEquals('target', $this->object->getTarget()); | ||
} | ||
|
||
/** | ||
* @covers Kunstmaan\RedirectBundle\Entity\Redirect::setPermanent | ||
* @covers Kunstmaan\RedirectBundle\Entity\Redirect::isPermanent | ||
*/ | ||
public function testGetSetPermanent() | ||
{ | ||
$this->object->setPermanent(true); | ||
$this->assertTrue($this->object->isPermanent()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace Kunstmaan\RedirectBundle\Tests\Form; | ||
|
||
use Kunstmaan\RedirectBundle\Form\RedirectAdminType; | ||
|
||
/** | ||
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-04-16 at 17:32:30. | ||
*/ | ||
class RedirectAdminTypeTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var RedirectAdminType | ||
*/ | ||
protected $object; | ||
|
||
/** | ||
* Sets up the fixture, for example, opens a network connection. | ||
* This method is called before a test is executed. | ||
*/ | ||
protected function setUp() | ||
{ | ||
$this->object = new RedirectAdminType(); | ||
} | ||
|
||
/** | ||
* Tears down the fixture, for example, closes a network connection. | ||
* This method is called after a test is executed. | ||
*/ | ||
protected function tearDown() | ||
{ | ||
} | ||
|
||
/** | ||
* @covers Kunstmaan\RedirectBundle\Form\RedirectAdminType::buildForm | ||
*/ | ||
public function testBuildForm() | ||
{ | ||
$builder = $this->getMock('Symfony\Component\Form\Test\FormBuilderInterface'); | ||
$builder | ||
->expects($this->at(0)) | ||
->method('add') | ||
->with('origin'); | ||
$builder | ||
->expects($this->at(1)) | ||
->method('add') | ||
->with('target'); | ||
$builder | ||
->expects($this->at(2)) | ||
->method('add') | ||
->with('permanent'); | ||
|
||
$this->object->buildForm($builder, array()); | ||
} | ||
|
||
/** | ||
* @covers Kunstmaan\RedirectBundle\Form\RedirectAdminType::getName | ||
*/ | ||
public function testGetName() | ||
{ | ||
$this->assertEquals('redirect_form', $this->object->getName()); | ||
} | ||
} |
Oops, something went wrong.