Skip to content

Commit

Permalink
Use new constructor helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
mpdude committed May 11, 2016
1 parent d7d3311 commit 103eba3
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions src/Test/SynchronizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,9 @@ public function synchronizeHandlesLongerSourceQueuesByCreatingNewObjects()
->method('createObject')
->with($idOfNewSourceObject, $this->className)
->will($this->returnValue($newlyCreatedObject));
$mapResult = new MapResult($newlyCreatedObject, false);
$this->mapper->expects($this->any())
->method('map')
->will($this->returnValue($mapResult));
->will($this->returnValue(MapResult::unchanged()));

$this->synchronizer->synchronize($this->className, false);
}
Expand All @@ -141,10 +140,9 @@ public function synchronizeCallsUpdatedAfterCreatingNewObject()
->method('createObject')
->with($idOfNewSourceObject, $this->className)
->will($this->returnValue($newlyCreatedObject));
$mapResult = new MapResult($newlyCreatedObject, false);
$this->mapper->expects($this->any())
->method('map')
->will($this->returnValue($mapResult));
->will($this->returnValue(MapResult::unchanged()));
$this->destination->expects($this->once())
->method('updated');

Expand All @@ -171,10 +169,9 @@ public function synchronizeCallsCommitAfterCreatingNewObject()
->method('createObject')
->with($idOfNewSourceObject, $this->className)
->will($this->returnValue($newlyCreatedObject));
$mapResult = new MapResult($newlyCreatedObject, false);
$this->mapper->expects($this->any())
->method('map')
->will($this->returnValue($mapResult));
->will($this->returnValue(MapResult::unchanged()));
$this->destination->expects($this->once())
->method('commit');

Expand Down Expand Up @@ -237,10 +234,9 @@ public function synchronizeHandlesSameSourceIdAsDestinationIdInQueueComparisonBy
$this->destination->expects($this->any())
->method('idOf')
->will($this->returnValue($sameIdForSourceAndDestinationObject));
$mapResult = new MapResult($olderVersionOfDestinationObject, true);
$this->mapper->expects($this->once())
->method('map')
->will($this->returnValue($mapResult));;
->will($this->returnValue(MapResult::changed($olderVersionOfDestinationObject)));;

$this->synchronizer->synchronize($this->className, false);
}
Expand All @@ -263,10 +259,9 @@ public function synchronizeCallsUpdatedForObjectsThatGotUpdated()
$this->destination->expects($this->any())
->method('idOf')
->will($this->returnValue($sameIdForSourceAndDestinationObject));
$mapResult = new MapResult($olderVersionOfDestinationObject, true);
$this->mapper->expects($this->once())
->method('map')
->will($this->returnValue($mapResult));;
->will($this->returnValue(MapResult::changed($olderVersionOfDestinationObject)));;

$this->destination->expects($this->once())
->method('updated')
Expand All @@ -293,10 +288,9 @@ public function synchronizeCallsCommitAfterUpdated()
$this->destination->expects($this->any())
->method('idOf')
->will($this->returnValue($sameIdForSourceAndDestinationObject));
$mapResult = new MapResult($olderVersionOfDestinationObject, true);
$this->mapper->expects($this->once())
->method('map')
->will($this->returnValue($mapResult, true));;
->will($this->returnValue(MapResult::changed($olderVersionOfDestinationObject), true));;
$this->destination->expects($this->once())
->method('updated');

Expand Down Expand Up @@ -324,10 +318,9 @@ public function synchronizeDoesNotCallUpdatedForObjectsThatRemainedTheSame()
$this->destination->expects($this->any())
->method('idOf')
->will($this->returnValue($sameIdForSourceAndDestinationObject));
$mapResult = new MapResult($olderVersionOfDestinationObject, false);
$this->mapper->expects($this->once())
->method('map')
->will($this->returnValue($mapResult));;
->will($this->returnValue(MapResult::unchanged()));;

$this->destination->expects($this->never())
->method('updated');
Expand Down Expand Up @@ -356,10 +349,9 @@ public function synchronizeCanBeForcedToUpdate()
$this->mapper->expects($this->once())
->method('setForce')
->with(true);
$mapResult = new MapResult($olderVersionOfDestinationObject, true);
$this->mapper->expects($this->once())
->method('map')
->will($this->returnValue($mapResult));;
->will($this->returnValue(MapResult::changed($olderVersionOfDestinationObject)));;

$this->destination->expects($this->once())
->method('updated');
Expand Down Expand Up @@ -392,10 +384,9 @@ public function synchronizeHandlesLowerSourceIdInQueueComparisonByCreatingObject
->method('createObject')
->with($idOfSourceObject, $this->className)
->will($this->returnValue($newlyCreatedObject));
$mapResult = new MapResult($newlyCreatedObject, true);
$this->mapper->expects($this->once())
->method('map')
->will($this->returnValue($mapResult));;
->will($this->returnValue(MapResult::changed($newlyCreatedObject)));;

$this->synchronizer->synchronize($this->className, false);
}
Expand All @@ -420,10 +411,9 @@ public function synchronizeHandlesHigherSourceIdInQueueComparisonByCreatingObjec
->method('idOf')
->will($this->returnValue($idOfDestinationObject));

$mapResult = new MapResult($destinationObject, true);
$this->mapper->expects($this->once())
->method('map')
->will($this->returnValue($mapResult));;
->will($this->returnValue(MapResult::changed($destinationObject)));;

$this->destination->expects($this->once())
->method('delete')
Expand Down

0 comments on commit 103eba3

Please sign in to comment.