-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added unit test for Form\RegisterFilter
- Loading branch information
1 parent
3ac9e38
commit db4390c
Showing
5 changed files
with
146 additions
and
53 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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
|
||
namespace PServerCMSTest\Form; | ||
|
||
|
||
use PServerCMSTest\Util\TestBase; | ||
|
||
class RegisterFilterTest extends TestBase | ||
{ | ||
/** @var string */ | ||
protected $className = '\PServerCMS\Form\RegisterFilter'; | ||
|
||
public function testIsValid() | ||
{ | ||
$this->mockedMethodList = [ | ||
'getUsernameValidator', | ||
'getUserNameBackendNotExistsValidator' | ||
]; | ||
|
||
$noRecordExistsMock = $this->getMockBuilder('PServerCMS\Validator\NoRecordExists') | ||
->disableOriginalConstructor() | ||
->setMethods(['isValid']) | ||
->getMock(); | ||
|
||
$noRecordExistsMock->expects($this->any()) | ||
->method('isValid') | ||
->willReturn(true); | ||
|
||
$UserNameBackendNotExistsMock = $this->getMockBuilder('PServerCMS\Validator\UserNameBackendNotExists') | ||
->disableOriginalConstructor() | ||
->setMethods(['isValid']) | ||
->getMock(); | ||
|
||
$UserNameBackendNotExistsMock->expects($this->any()) | ||
->method('isValid') | ||
->willReturn(true); | ||
|
||
$class = $this->getClass(); | ||
|
||
$class->expects($this->any()) | ||
->method('getUsernameValidator') | ||
->willReturn($noRecordExistsMock); | ||
|
||
$class->expects($this->any()) | ||
->method('getUserNameBackendNotExistsValidator') | ||
->willReturn($UserNameBackendNotExistsMock); | ||
|
||
$class->__construct($this->serviceManager); | ||
|
||
$class->setData([ | ||
'username' => 'fodfgo', | ||
'email' => 'fodfgo@travel.com', | ||
'emailVerify' => 'fodfgo@travel.com', | ||
'password' => 'fodfgo', | ||
'passwordVerify' => 'fodfgo', | ||
]); | ||
|
||
$this->assertTrue($class->isValid()); | ||
} | ||
|
||
/** | ||
* @return \PServerCMS\Form\RegisterFilter|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected function getClass() | ||
{ | ||
if (!$this->class) { | ||
/** @var \Zend\ServiceManager\ServiceManagerAwareInterface $class */ | ||
$class = $this->getMockBuilder($this->className) | ||
->disableOriginalConstructor() | ||
->setMethods($this->getMockedMethodList()) | ||
->getMock(); | ||
|
||
$this->class = $class; | ||
} | ||
|
||
return $this->class; | ||
} | ||
|
||
} |
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,17 @@ | ||
<?php | ||
|
||
|
||
namespace PServerCMSTest\Service; | ||
|
||
|
||
use PServerCMSTest\Util\TestBase; | ||
|
||
class UserTest extends TestBase | ||
{ | ||
|
||
public function testRegister() | ||
{ | ||
$this->markTestSkipped('need to refactor the method first'); | ||
} | ||
|
||
} |
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