mirror of
https://github.com/Respect/Validation.git
synced 2024-06-07 08:12:16 +02:00
Mock malkusch\bav\BAV
on tests
This commit is contained in:
parent
84375f436d
commit
d0f07ecc5f
|
@ -32,6 +32,11 @@
|
|||
"Respect\\Validation\\": "library/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Respect\\Validation\\Test\\": "tests/library/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "0.8-dev"
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Test\LocaleTestCase;
|
||||
|
||||
/**
|
||||
* @covers Respect\Validation\Rules\BankAccount
|
||||
*/
|
||||
class BankAccountTest extends \PHPUnit_Framework_TestCase
|
||||
class BankAccountTest extends LocaleTestCase
|
||||
{
|
||||
public function testShouldUseDefinedFactoryToCreateInternalRuleBasedOnGivenCountryCode()
|
||||
{
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Test\LocaleTestCase;
|
||||
|
||||
/**
|
||||
* @covers Respect\Validation\Rules\Bank
|
||||
*/
|
||||
class BankTest extends \PHPUnit_Framework_TestCase
|
||||
class BankTest extends LocaleTestCase
|
||||
{
|
||||
public function testShouldUseDefinedFactoryToCreateInternalRuleBasedOnGivenCountryCode()
|
||||
{
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Test\LocaleTestCase;
|
||||
|
||||
/**
|
||||
* @covers Respect\Validation\Rules\Bic
|
||||
*/
|
||||
class BicTest extends \PHPUnit_Framework_TestCase
|
||||
class BicTest extends LocaleTestCase
|
||||
{
|
||||
public function testShouldUseDefinedFactoryToCreateInternalRuleBasedOnGivenCountryCode()
|
||||
{
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
namespace Respect\Validation\Rules\Locale;
|
||||
|
||||
use Respect\Validation\Test\LocaleTestCase;
|
||||
|
||||
/**
|
||||
* @covers Respect\Validation\Rules\Locale\Factory
|
||||
*/
|
||||
class FactoryTest extends \PHPUnit_Framework_TestCase
|
||||
class FactoryTest extends LocaleTestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException Respect\Validation\Exceptions\ComponentException
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
namespace Respect\Validation\Rules\Locale;
|
||||
|
||||
use malkusch\bav\BAV;
|
||||
use Respect\Validation\Test\LocaleTestCase;
|
||||
|
||||
/**
|
||||
* @covers Respect\Validation\Rules\Locale\GermanBankAccount
|
||||
* @covers Respect\Validation\Exceptions\Locale\GermanBankAccountException
|
||||
*/
|
||||
class GermanBankAccountTest extends \PHPUnit_Framework_TestCase
|
||||
class GermanBankAccountTest extends LocaleTestCase
|
||||
{
|
||||
public function testShouldAcceptBankOnConstructor()
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ class GermanBankAccountTest extends \PHPUnit_Framework_TestCase
|
|||
public function testShouldAcceptBAVInstanceOnConstructor()
|
||||
{
|
||||
$bank = '10000000';
|
||||
$bav = new BAV();
|
||||
$bav = $this->getBavMock();
|
||||
$rule = new GermanBankAccount($bank, $bav);
|
||||
|
||||
$this->assertSame($bav, $rule->bav);
|
||||
|
@ -38,7 +38,7 @@ class GermanBankAccountTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
$bank = '10000000';
|
||||
$input = '67067';
|
||||
$bav = $this->getMock('malkusch\bav\BAV');
|
||||
$bav = $this->getBavMock();
|
||||
$rule = new GermanBankAccount($bank, $bav);
|
||||
|
||||
$bav->expects($this->once())
|
||||
|
@ -53,7 +53,7 @@ class GermanBankAccountTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
$bank = '10000000';
|
||||
$input = '67067';
|
||||
$bav = $this->getMock('malkusch\bav\BAV');
|
||||
$bav = $this->getBavMock();
|
||||
$rule = new GermanBankAccount($bank, $bav);
|
||||
|
||||
$bav->expects($this->any())
|
||||
|
@ -72,7 +72,7 @@ class GermanBankAccountTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
$bank = '10000000';
|
||||
$input = '67067';
|
||||
$bav = $this->getMock('malkusch\bav\BAV');
|
||||
$bav = $this->getBavMock();
|
||||
$rule = new GermanBankAccount($bank, $bav);
|
||||
|
||||
$bav->expects($this->any())
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
<?php
|
||||
namespace Respect\Validation\Rules\Locale;
|
||||
|
||||
use malkusch\bav\BAV;
|
||||
use Respect\Validation\Test\LocaleTestCase;
|
||||
|
||||
/**
|
||||
* @covers Respect\Validation\Rules\Locale\GermanBank
|
||||
* @covers Respect\Validation\Exceptions\Locale\GermanBankException
|
||||
*/
|
||||
class GermanBankTest extends \PHPUnit_Framework_TestCase
|
||||
class GermanBankTest extends LocaleTestCase
|
||||
{
|
||||
public function testShouldAcceptBAVInstanceOnConstrutor()
|
||||
{
|
||||
$bav = new BAV();
|
||||
$bav = $this->getBavMock();
|
||||
$rule = new GermanBank($bav);
|
||||
|
||||
$this->assertSame($bav, $rule->bav);
|
||||
|
@ -27,7 +27,7 @@ class GermanBankTest extends \PHPUnit_Framework_TestCase
|
|||
public function testShouldUseBAVInstanceToValidate()
|
||||
{
|
||||
$input = '10000000';
|
||||
$bav = $this->getMock('malkusch\bav\BAV');
|
||||
$bav = $this->getBavMock();
|
||||
$rule = new GermanBank($bav);
|
||||
|
||||
$bav->expects($this->once())
|
||||
|
@ -41,7 +41,7 @@ class GermanBankTest extends \PHPUnit_Framework_TestCase
|
|||
public function testShouldReturnBAVInstanceResulteWhenValidating()
|
||||
{
|
||||
$input = '10000000';
|
||||
$bav = $this->getMock('malkusch\bav\BAV');
|
||||
$bav = $this->getBavMock();
|
||||
$rule = new GermanBank($bav);
|
||||
|
||||
$bav->expects($this->any())
|
||||
|
@ -59,7 +59,7 @@ class GermanBankTest extends \PHPUnit_Framework_TestCase
|
|||
public function testShouldThowsTheRightExceptionWhenChecking()
|
||||
{
|
||||
$input = '10000000';
|
||||
$bav = $this->getMock('malkusch\bav\BAV');
|
||||
$bav = $this->getBavMock();
|
||||
$rule = new GermanBank($bav);
|
||||
|
||||
$bav->expects($this->any())
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
<?php
|
||||
namespace Respect\Validation\Rules\Locale;
|
||||
|
||||
use malkusch\bav\BAV;
|
||||
use Respect\Validation\Test\LocaleTestCase;
|
||||
|
||||
/**
|
||||
* @covers Respect\Validation\Rules\Locale\GermanBic
|
||||
* @covers Respect\Validation\Exceptions\Locale\GermanBicException
|
||||
*/
|
||||
class GermanBicTest extends \PHPUnit_Framework_TestCase
|
||||
class GermanBicTest extends LocaleTestCase
|
||||
{
|
||||
public function testShouldAcceptBAVInstanceOnConstrutor()
|
||||
{
|
||||
$bav = new BAV();
|
||||
$bav = $this->getBavMock();
|
||||
$rule = new GermanBic($bav);
|
||||
|
||||
$this->assertSame($bav, $rule->bav);
|
||||
|
@ -27,7 +27,7 @@ class GermanBicTest extends \PHPUnit_Framework_TestCase
|
|||
public function testShouldUseBAVInstanceToValidate()
|
||||
{
|
||||
$input = '10000000';
|
||||
$bav = $this->getMock('malkusch\bav\BAV');
|
||||
$bav = $this->getBavMock();
|
||||
$rule = new GermanBic($bav);
|
||||
|
||||
$bav->expects($this->once())
|
||||
|
@ -41,7 +41,7 @@ class GermanBicTest extends \PHPUnit_Framework_TestCase
|
|||
public function testShouldReturnBAVInstanceResulteWhenValidating()
|
||||
{
|
||||
$input = '10000000';
|
||||
$bav = $this->getMock('malkusch\bav\BAV');
|
||||
$bav = $this->getBavMock();
|
||||
$rule = new GermanBic($bav);
|
||||
|
||||
$bav->expects($this->any())
|
||||
|
@ -59,7 +59,7 @@ class GermanBicTest extends \PHPUnit_Framework_TestCase
|
|||
public function testShouldThowsTheRightExceptionWhenChecking()
|
||||
{
|
||||
$input = '10000000';
|
||||
$bav = $this->getMock('malkusch\bav\BAV');
|
||||
$bav = $this->getBavMock();
|
||||
$rule = new GermanBic($bav);
|
||||
|
||||
$bav->expects($this->any())
|
||||
|
|
29
tests/library/LocaleTestCase.php
Normal file
29
tests/library/LocaleTestCase.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
namespace Respect\Validation\Test;
|
||||
|
||||
use malkusch\bav\ConfigurationRegistry;
|
||||
|
||||
class LocaleTestCase extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function getBavMock()
|
||||
{
|
||||
$bavMock = $this->getMockBuilder('malkusch\bav\BAV')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
return $bavMock;
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$dataBackend = $this->getMockForAbstractClass('malkusch\bav\DataBackend');
|
||||
$dataBackendContainer = $this->getMockForAbstractClass('malkusch\bav\DataBackendContainer');
|
||||
$dataBackendContainer
|
||||
->expects($this->any())
|
||||
->method('makeDataBackend')
|
||||
->will($this->returnValue($dataBackend));
|
||||
|
||||
ConfigurationRegistry::getConfiguration()->setDataBackendContainer($dataBackendContainer);
|
||||
ConfigurationRegistry::getConfiguration()->setUpdatePlan(null);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue