Source of file DbJobTest.php
Size: 1,096 Bytes - Last Modified: 2021-12-23T10:38:27+00:00
/var/www/docs.ssmods.com/process/src/tests/DbJobTest.php
123456789101112131415161718192021222324252627282930313233343536373839 | <?php namespace StudioBonito\SilverStripe\Queue\Tests; use Mockery as m; class DbJobTest extends \PHPUnit_Framework_TestCase { public function tearDown() { m::close(); } public function testRunProperlyCallsTheJobHandler() { $job = $this->getJob(); $job->getInjector()->shouldReceive('get')->once()->with('foo')->andReturn($handler = m::mock('StdClass')); $handler->shouldReceive('run')->once()->with($job, array('data')); $job->run(); } protected function getJob() { $jobQueue = m::mock('StudioBonito\SilverStripe\Queue\Models\JobQueue'); $jobQueue->shouldReceive('hasMethod')->with('getPayload')->andReturn(true); $jobQueue->shouldReceive('getPayload')->andReturn( json_encode(array('job' => 'foo', 'data' => array('data'), 'attempts' => 1)) ); return new \StudioBonito\SilverStripe\Queue\Jobs\DbJob( m::mock('Injector'), m::mock('StudioBonito\SilverStripe\Queue\DbQueue'), $jobQueue, 'default' ); } } |