Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeboer committed Jan 21, 2017
1 parent dcd36c8 commit 3deba40
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
13 changes: 0 additions & 13 deletions tests/Mock/Vies/Response/CheckVatResponse.php

This file was deleted.

29 changes: 19 additions & 10 deletions tests/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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));
}

Expand All @@ -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));
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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;
}

}
2 changes: 1 addition & 1 deletion tests/Vies/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3deba40

Please sign in to comment.