-
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.
Add units tests Test For SonataGroup and CreateUserCommand Functions AddRoles(), RemoveRole(), AddUser(), RemoveUser(). Disable Functionnal Test
- Loading branch information
1 parent
317ac36
commit bbe0dcf
Showing
6 changed files
with
319 additions
and
8 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
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,33 @@ | ||
<?php | ||
|
||
namespace Librinfo\SonataSyliusUserBundle\Tests\Functional; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; | ||
use Symfony\Component\DependencyInjection\Container; | ||
|
||
class BundleTest extends KernelTestCase | ||
{ | ||
|
||
protected $container; | ||
|
||
protected function setUp() { | ||
static::bootKernel(); | ||
|
||
/** @var Container $container */ | ||
$this->container = self::$kernel->getContainer(); | ||
} | ||
|
||
public function testServicesAreInitializable() { | ||
|
||
$this->markTestIncomplete('This test has not been implemented yet.'); | ||
|
||
$serviceIds = array_filter($this->container->getServiceIds(), function ($serviceId) { | ||
return 0 === strpos($serviceId, "sonata_sylius_user" . '.'); | ||
}); | ||
|
||
foreach ($serviceIds as $serviceId) { | ||
$this->assertNotNull($this->container->get($serviceId)); | ||
} | ||
} | ||
|
||
} |
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,59 @@ | ||
<?php | ||
|
||
namespace Librinfo\SonataSyliusUserBundle\Command\Test\Unit; | ||
|
||
use Librinfo\SonataSyliusUserBundle\Command\CreateUserCommand; | ||
/* * Librinfo\SonataSyliusUserBundle\Command\CreateUserCommand' | ||
* Generated by PHPUnit_SkeletonGenerator on 2017-05-02 at 16:34:40. | ||
*/ | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class CreateUserCommandTest extends TestCase | ||
{ | ||
|
||
/** | ||
* @var CreateUserCommand | ||
*/ | ||
protected $myCommand; | ||
protected $myConfig; | ||
|
||
/** | ||
* Sets up the fixture, for example, opens a network connection. | ||
* This method is called before a test is executed. | ||
*/ | ||
protected function setUp() { | ||
$this->myCommand = new CreateUserCommand(); | ||
} | ||
|
||
/** | ||
* Tears down the fixture, for example, closes a network connection. | ||
* This method is called after a test is executed. | ||
*/ | ||
protected function tearDown() { | ||
|
||
} | ||
|
||
/** | ||
* @covers Librinfo\SonataSyliusUserBundle\Command\CreateUserCommand::configure | ||
* @todo Implement testConfigure(). | ||
*/ | ||
public function testConfigure() { | ||
$this->markTestIncomplete('This test has not been implemented yet.'); | ||
|
||
$this->myCommand->configure(); | ||
|
||
$this->myConfig = $this->myCommand->getName(); | ||
/** | ||
* @todo : check if we need to test more (or not) | ||
*/ | ||
$this->assertContains('user', $this->myConfig); | ||
} | ||
|
||
public function testExecute() { | ||
|
||
/* | ||
* @todo : Is it really relevant to perform tests on it? | ||
*/ | ||
} | ||
|
||
} |
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,212 @@ | ||
<?php | ||
|
||
namespace Librinfo\SonataSyliusUserBundle\Entity\Test\Unit; | ||
|
||
use Librinfo\SonataSyliusUserBundle\Entity\SonataGroup; | ||
use Symfony\Component\Security\Core\User\AdvancedUserInterface; | ||
/** | ||
* Generated by PHPUnit_SkeletonGenerator on 2017-05-10 at 17:49:31. | ||
*/ | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class SonataGroupTest extends TestCase | ||
{ | ||
|
||
/** | ||
* @var SonataGroup | ||
*/ | ||
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 SonataGroup; | ||
} | ||
|
||
/** | ||
* Tears down the fixture, for example, closes a network connection. | ||
* This method is called after a test is executed. | ||
*/ | ||
protected function tearDown() { | ||
|
||
} | ||
|
||
/** | ||
* @covers Librinfo\SonataSyliusUserBundle\Entity\SonataGroup::__toString | ||
* @todo Implement test__toString(). | ||
*/ | ||
public function test__toString() { | ||
// Remove the following lines when you implement this test. | ||
$this->markTestIncomplete('This test has not been implemented yet.'); | ||
} | ||
|
||
/** | ||
* @covers Librinfo\SonataSyliusUserBundle\Entity\SonataGroup::addRole | ||
* @todo Implement testAddRole(). | ||
*/ | ||
public function testAddRole() { | ||
/** | ||
* @todo 1.appeler addRole | ||
* 2. appeler getRoles | ||
* 3. faire un assert pour vérifier que le role qu'on a passer a addRoles | ||
* est bien dans le resultat de getRoles | ||
*/ | ||
$role = 'foo'; | ||
|
||
$this->object->addRole($role); | ||
|
||
$listRoles = $this->object->getRoles(); | ||
|
||
// we search 'foo' in uppercase because addRoles transform a string in uppercase | ||
$this->assertContains('FOO', $listRoles); | ||
} | ||
|
||
/** | ||
* @covers Librinfo\SonataSyliusUserBundle\Entity\SonataGroup::getId | ||
* @todo Implement testGetId(). | ||
*/ | ||
public function testGetId() { | ||
// Remove the following lines when you implement this test. | ||
$this->markTestIncomplete('This test has not been implemented yet.'); | ||
} | ||
|
||
/** | ||
* @covers Librinfo\SonataSyliusUserBundle\Entity\SonataGroup::getName | ||
* @todo Implement testGetName(). | ||
*/ | ||
public function testGetName() { | ||
// Remove the following lines when you implement this test. | ||
$this->markTestIncomplete('This test has not been implemented yet.'); | ||
} | ||
|
||
/** | ||
* @covers Librinfo\SonataSyliusUserBundle\Entity\SonataGroup::hasRole | ||
* @todo Implement testHasRole(). | ||
*/ | ||
public function testHasRole() { | ||
// Remove the following lines when you implement this test. | ||
$this->markTestIncomplete('This test has not been implemented yet.'); | ||
} | ||
|
||
/** | ||
* @covers Librinfo\SonataSyliusUserBundle\Entity\SonataGroup::getRoles | ||
* @todo Implement testGetRoles(). | ||
*/ | ||
public function testGetRoles() { | ||
// Remove the following lines when you implement this test. | ||
$this->markTestIncomplete('This test has not been implemented yet.'); | ||
} | ||
|
||
/** | ||
* @covers Librinfo\SonataSyliusUserBundle\Entity\SonataGroup::removeRole | ||
* @todo Implement testRemoveRole(). | ||
*/ | ||
public function testRemoveRole() { | ||
$role = 'foo'; | ||
$role2 = 'bar'; | ||
$role3 = 'zoo'; | ||
|
||
$this->object->addRole($role); | ||
$this->object->addRole($role2); | ||
$this->object->addRole($role3); | ||
|
||
$listRoles = $this->object->getRoles(); | ||
|
||
$this->object->removeRole($role2); | ||
//we call again getRoles() for refresh the array | ||
$listRoles = $this->object->getRoles(); | ||
|
||
$this->assertNotContains('bar', $listRoles); | ||
} | ||
|
||
/** | ||
* @covers Librinfo\SonataSyliusUserBundle\Entity\SonataGroup::setName | ||
* @todo Implement testSetName(). | ||
*/ | ||
public function testSetName() { | ||
// Remove the following lines when you implement this test. | ||
$this->markTestIncomplete('This test has not been implemented yet.'); | ||
} | ||
|
||
/** | ||
* @covers Librinfo\SonataSyliusUserBundle\Entity\SonataGroup::setRoles | ||
* @todo Implement testSetRoles(). | ||
*/ | ||
public function testSetRoles() { | ||
// Remove the following lines when you implement this test. | ||
$this->markTestIncomplete('This test has not been implemented yet.'); | ||
} | ||
|
||
/** | ||
* @covers Librinfo\SonataSyliusUserBundle\Entity\SonataGroup::addUser | ||
* @todo Implement testAddUser(). | ||
*/ | ||
public function testAddUser() { | ||
$this->markTestIncomplete('This test has not been implemented yet.'); | ||
|
||
$toto = 'weekend'; | ||
$user = $this->getMockForAbstractClass(AdvancedUserInterface::class); | ||
|
||
$get = $this->object->addUser($user)->getUsers(); | ||
|
||
$this->assertNotNull($get); | ||
} | ||
|
||
/** | ||
* @covers Librinfo\SonataSyliusUserBundle\Entity\SonataGroup::removeUser | ||
* @todo Implement testRemoveUser(). | ||
*/ | ||
public function testRemoveUser() { | ||
$this->markTestIncomplete('This test has not been implemented yet.'); | ||
|
||
$toto = 'lundi matin'; | ||
$user = $this | ||
->getMockForAbstractClass(AdvancedUserInterface::class); | ||
$this->object->addUser($user); | ||
$get = $this->object->getUsers(); | ||
|
||
$get = $this->object->removeUser($user); | ||
$get = $this->object->getUsers(); | ||
|
||
$this->assertEquals(0, $get->count()); | ||
} | ||
|
||
/** | ||
* @covers Librinfo\SonataSyliusUserBundle\Entity\SonataGroup::getUsers | ||
* @todo Implement testGetUsers(). | ||
*/ | ||
public function testGetUsers() { | ||
// Remove the following lines when you implement this test. | ||
$this->markTestIncomplete('This test has not been implemented yet.'); | ||
} | ||
|
||
/** | ||
* @covers Librinfo\SonataSyliusUserBundle\Entity\SonataGroup::setUsers | ||
* @todo Implement testSetUsers(). | ||
*/ | ||
public function testSetUsers() { | ||
// Remove the following lines when you implement this test. | ||
$this->markTestIncomplete('This test has not been implemented yet.'); | ||
} | ||
|
||
/** | ||
* @covers Librinfo\SonataSyliusUserBundle\Entity\SonataGroup::setId | ||
* @todo Implement testSetId(). | ||
*/ | ||
public function testSetId() { | ||
// Remove the following lines when you implement this test. | ||
$this->markTestIncomplete('This test has not been implemented yet.'); | ||
} | ||
|
||
/** | ||
* @covers Librinfo\SonataSyliusUserBundle\Entity\SonataGroup::isNew | ||
* @todo Implement testIsNew(). | ||
*/ | ||
public function testIsNew() { | ||
// Remove the following lines when you implement this test. | ||
$this->markTestIncomplete('This test has not been implemented yet.'); | ||
} | ||
|
||
} |