From 3deba40999cea52d067333146ff184f89537d96b Mon Sep 17 00:00:00 2001 From: David de Boer Date: Sat, 21 Jan 2017 19:04:03 +0100 Subject: [PATCH] Fix tests --- tests/Mock/Vies/Response/CheckVatResponse.php | 13 --------- tests/ValidatorTest.php | 29 ++++++++++++------- tests/Vies/ClientTest.php | 2 +- 3 files changed, 20 insertions(+), 24 deletions(-) delete mode 100644 tests/Mock/Vies/Response/CheckVatResponse.php diff --git a/tests/Mock/Vies/Response/CheckVatResponse.php b/tests/Mock/Vies/Response/CheckVatResponse.php deleted file mode 100644 index e41185c..0000000 --- a/tests/Mock/Vies/Response/CheckVatResponse.php +++ /dev/null @@ -1,13 +0,0 @@ -valid = $valid; - } -} \ No newline at end of file diff --git a/tests/ValidatorTest.php b/tests/ValidatorTest.php index f3ebc3f..6260025 100644 --- a/tests/ValidatorTest.php +++ b/tests/ValidatorTest.php @@ -15,11 +15,6 @@ public function setUp() $this->validator = new Validator(); } - public function testViesClient() - { - $this->assertInstanceOf('\Ddeboer\Vatin\Vies\Client', $this->validator->getViesClient()); - } - /** * @dataProvider getValidVatins */ @@ -43,9 +38,9 @@ public function testValidWithVies() ->expects($this->once()) ->method('checkVat') ->with('NL', '002065538B01') - ->will($this->returnValue(new CheckVatResponse(true))); + ->willReturn($this->getCheckVatResponseMock(true)); - $this->validator->setViesClient($client); + $this->validator = new Validator($client); $this->assertTrue($this->validator->isValid('NL002065538B01', true)); } @@ -56,9 +51,9 @@ public function testInvalidWithVies() ->expects($this->once()) ->method('checkVat') ->with('NL', '123456789B01') - ->will($this->returnValue(new CheckVatResponse(false))); + ->willReturn($this->getCheckVatResponseMock(false)); - $this->validator->setViesClient($client); + $this->validator = new Validator($client); $this->assertFalse($this->validator->isValid('NL123456789B01', true)); } @@ -67,7 +62,7 @@ public function testWrongConnectionThrowsException() { $this->setExpectedException('\Ddeboer\Vatin\Exception\ViesException'); - $this->validator->setViesClient(new Client('http//google.com')); + $this->validator = new Validator(new Client('meh')); $this->validator->isValid('NL002065538B01', true); } @@ -176,4 +171,18 @@ private function getViesClientMock() ->disableOriginalConstructor() ->getMock(); } + + private function getCheckVatResponseMock($valid) + { + $mock = $this->getMockBuilder('\Ddeboer\Vatin\Vies\Response\CheckVatResponse') + ->getMock(); + + $mock + ->expects($this->any()) + ->method('isValid') + ->willReturn($valid); + + return $mock; + } + } diff --git a/tests/Vies/ClientTest.php b/tests/Vies/ClientTest.php index 9a4338e..65a0685 100644 --- a/tests/Vies/ClientTest.php +++ b/tests/Vies/ClientTest.php @@ -8,7 +8,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase { public function testCheckVat() { - $client = new Client('http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl'); + $client = new Client(); $response = $client->checkVat('NL', '123456789B01'); $this->assertInstanceOf('\Ddeboer\Vatin\Vies\Response\CheckVatResponse', $response);