respect-validation/tests/Rules/Locale/FactoryTest.php
2015-01-19 11:01:00 -02:00

80 lines
2.4 KiB
PHP

<?php
namespace Respect\Validation\Rules\Locale;
/**
* @covers Respect\Validation\Rules\Locale\Factory
*/
class FactoryTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException Respect\Validation\Exceptions\ComponentException
* @expectedExceptionMessage Cannot provide BIC validation for country "XX"
*/
public function testShouldThrowExceptionWhenFailedToGetBICRule()
{
$factory = new Factory();
$factory->bic('XX');
}
public function testShouldReturnBICRuleAccordingToCountry()
{
$factory = new Factory();
$this->assertInstanceOf('Respect\Validation\Validatable', $factory->bic('DE'));
}
public function testShouldNotBeCaseSensitiveToReturnBICRuleAccordingToCountry()
{
$factory = new Factory();
$this->assertEquals($factory->bic('DE'), $factory->bic('de'));
}
/**
* @expectedException Respect\Validation\Exceptions\ComponentException
* @expectedExceptionMessage Cannot provide bank validation for country "XX"
*/
public function testShouldThrowExceptionWhenFailedToGetBankRule()
{
$factory = new Factory();
$factory->bank('XX');
}
public function testShouldReturnBankRuleAccordingToCountry()
{
$factory = new Factory();
$this->assertInstanceOf('Respect\Validation\Validatable', $factory->bank('DE'));
}
public function testShouldNotBeCaseSensitiveToReturnBankRuleAccordingToCountry()
{
$factory = new Factory();
$this->assertEquals($factory->bank('DE'), $factory->bank('de'));
}
/**
* @expectedException Respect\Validation\Exceptions\ComponentException
* @expectedExceptionMessage Cannot provide bank account validation for country "XX" and bank "123"
*/
public function testShouldThrowExceptionWhenFailedToGetBankAccountRule()
{
$factory = new Factory();
$factory->bankAccount('XX', '123');
}
public function testShouldReturnBankAccountRuleAccordingToCountry()
{
$factory = new Factory();
$this->assertInstanceOf('Respect\Validation\Validatable', $factory->bankAccount('DE', '123'));
}
public function testShouldNotBeCaseSensitiveToReturnBankAccountRuleAccordingToCountry()
{
$factory = new Factory();
$this->assertEquals($factory->bankAccount('DE', '123'), $factory->bankAccount('de', '123'));
}
}