Skip to content

Instantly share code, notes, and snippets.

@srdjanmarjanovic
Created November 17, 2017 09:09
Show Gist options
  • Save srdjanmarjanovic/75491b3809b6bad2bb21aeefe08e5d5d to your computer and use it in GitHub Desktop.
Save srdjanmarjanovic/75491b3809b6bad2bb21aeefe08e5d5d to your computer and use it in GitHub Desktop.
Mocking and testing mocks
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