Created
November 17, 2017 09:09
-
-
Save srdjanmarjanovic/75491b3809b6bad2bb21aeefe08e5d5d to your computer and use it in GitHub Desktop.
Mocking and testing mocks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pulic function setUp() | |
{ | |
$this->syncer = $this->createMock(SyncUtilityInterface::class); | |
$this->jobs = $this->createMock(JobsDispatcherInterface::class); | |
$this->jobs_preparer = new PrepareSyncJobs( | |
$this->syncer, | |
$this->jobs | |
); | |
} | |
public function testJobIsDispatchedAndRecordIsReservedWhenEntityCreated() | |
{ | |
$dummy_data = [ | |
['id' => 1, 'entity_id' => 1] | |
]; | |
$this->jobs | |
->expects($this->exactly(1)) | |
->method('dispatch'); | |
$this->syncer | |
->expects($this->exactly(1)) | |
->method('markRecordsAsReserved') | |
->with(array_column($dummy_data[0], 'id')); | |
$this->jobs_preparer->prepareEntityCreatedJobs($dummy_data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment