Skip to content

Get visit service#6

Merged
killianherbunot merged 6 commits intomasterfrom
get_visit_service
Oct 25, 2016
Merged

Get visit service#6
killianherbunot merged 6 commits intomasterfrom
get_visit_service

Conversation

@killianherbunot
Copy link
Contributor

No description provided.


/**
* @param string $resourceName
* @param object $resourceData

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

array

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nop

interface VisitGateway
{
/**
* @param integer $personId

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about "from" and "to" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

private $visit;

/**
* @return VisitBuilder

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inheritdoc (same for the entire method of this class)

*/
class VisitRepository implements VisitGateway
{
const RESOURCE_NAME = 'desk/people/';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't add the last "/" for other resource name do the same here

*/
class VisitRepositoryTest extends \PHPUnit_Framework_TestCase
{
const FROM = "2016-08-12 15:30:06";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

single quote

*/
public function findAllByPersonIdWithoutParameters_ReturnVisits()
{
ApiClientMock::$response = json_encode(["visits" => [new VisitStub1()], "total_count" => 1]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

public function findAllByPersonIdWithParameters_ReturnVisits()
{
list($from, $to) = $this->initFromAndTo();
ApiClientMock::$response = json_encode(["visits" => [new VisitStub1()], "total_count" => 1]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and same

ApiClientMock::$response = json_encode(["visits" => [new VisitStub1()], "total_count" => 1]);

$visits = $this->visitRepository->findAllByPersonId(PersonStub1::ID);
$this->assertEquals(json_encode([new VisitStub1()]), json_encode($visits));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about the use of the assertVisit in VisitTestCase trait ?

/**
* @param Visit[] $visits
*/
public function doTestVisit($visits)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertVisits

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure, i'm only test one visit at a time.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nop, you test an array of visit ;)

*/
public function doTestVisit($visits)
{
$this->assertEquals(0, count($visits) - count(VisitGatewayMock::$visits));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?


$plans = $this->planRepository->findAllByPersonId(PersonStub1::ID);
$this->assertEquals(json_encode([new PlanStub1()]), json_encode($plans));
$this->assertEquals(0, count($plans) - count(PlanGatewayMock::$plans));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useless

{
$this->planRepository = new PlanRepository();
$this->planRepository->setApiClient(new ApiClientMock());
PlanGatewayMock::$plans = new PlanStub1();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

*/
public function doTestVisits($visits)
{
$this->assertEquals(0, count($visits) - count(VisitGatewayMock::$visits));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useless

{
$this->visitRepository = new VisitRepository();
$this->visitRepository->setApiClient(new ApiClientMock());
VisitGatewayMock::$visits = new VisitStub1();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useless

/**
* @param Visit[] $visits
*/
public function doTestVisits($visits)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertVisits and you can move it on VisitTestCase Trait

/**
* @param Visit[] $visits
*/
public function assertVisits($visits)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(array $visits) :)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need it in your VisitServiceImpl too

@killianherbunot killianherbunot merged commit 75bdc0e into master Oct 25, 2016
@killianherbunot killianherbunot deleted the get_visit_service branch October 26, 2016 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants