Skip to content

Instantly share code, notes, and snippets.

@gallna
Created July 24, 2015 15:33
Show Gist options
  • Save gallna/f095477c81d4292391ff to your computer and use it in GitHub Desktop.
Save gallna/f095477c81d4292391ff to your computer and use it in GitHub Desktop.
DirectorServiceTest.php
<?php
use hurricane\directorservice\app\DirectorService;
use hurricane\directorservice\domain;
use hurricane\directorservice\domain\fields\director\summary;
use companycheck\services\auth;
use companycheck\services\clients;
class DirectorServiceTest extends \PHPUnit_Framework_TestCase
{
public function searchClient()
{
$searchClient = $this->getMockBuilder('companycheck\services\clients\searchClient')
->disableOriginalConstructor()
->getMock();
$searchClient->expects($this->any())
->method('id')
->will($this->returnValue($searchClient));
$searchClient->expects($this->any())
->method('type')
->will($this->returnValue($searchClient));
$searchClient->expects($this->any())
->method('status')
->will($this->returnValue($searchClient));
$searchClient->expects($this->any())
->method('currentappointment')
->will($this->returnValue($searchClient));
$searchClient->expects($this->any())
->method('previousappointment')
->will($this->returnValue($searchClient));
$searchClient->expects($this->any())
->method('appointment')
->will($this->returnValue($searchClient));
$searchClient->expects($this->any())
->method('appointment')
->will($this->returnValue($searchClient));
$searchClient->expects($this->any())
->method('page')
->will($this->returnValue($searchClient));
$searchClient->expects($this->any())
->method('size')
->will($this->returnValue($searchClient));
$jsonResponse = $this->getMockBuilder('companycheck\services\response\jsonResponse')
->getMock();
$jsonResponse->expects($this->any())
->method('getResponse')
->will($this->returnValue(json_decode(file_get_contents(__DIR__."/searchResponse.json"))->response));
$searchClient->expects($this->any())
->method('search')
->will($this->returnValue($jsonResponse));
return $searchClient;
}
public function testValidParseQuery()
{
$searchClient = $this->searchClient();
$dir = new DirectorService(
new S3ClientMock,
new \stdClass(['fields' =>['companysummary']]),
new companyClientMock(new auth\noAuth),
$searchClient
);
$dir->parseQuery();
}
public function testValidSummary()
{
$searchClient = $this->searchClient();
$summary = new summary(
(new S3ClientMock)->getDirectorXml(),
new companyClientMock(new auth\noAuth),
$searchClient
);
$summary->getJson();
}
}
class S3ClientMock implements hurricane\directorservice\clients\DirectorDataInterface
{
public function getDirectorXml()
{
return new domain\DirectorXml(file_get_contents(__DIR__.'/07204805.xml'));
}
}
class companyClientMock extends clients\companyClient
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment