Source of file SyncJobTest.php
Size: 1,411 Bytes - Last Modified: 2021-12-23T10:38:27+00:00
/var/www/docs.ssmods.com/process/src/tests/SyncJobTest.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 | <?php namespace StudioBonito\SilverStripe\Queue\Tests; use Injector; use Mockery as m; class SyncJobTest extends \PHPUnit_Framework_TestCase { public function tearDown() { m::close(); } public function testRunResolvesAndRunsJobClass() { $injector = m::mock('Injector'); $job = new \StudioBonito\SilverStripe\Queue\Jobs\SyncJob($injector, 'Foo', '"data"'); $handler = m::mock('StdClass'); $injector->shouldReceive('get')->once()->with('Foo')->andReturn($handler); $handler->shouldReceive('run')->once()->with($job, 'data'); $job->run(); } public function testClosuresCanBeRunBySyncJob() { unset($_SERVER['__queue.closure']); $job = new \StudioBonito\SilverStripe\Queue\Jobs\SyncJob(new Injector(), function () { $_SERVER['__queue.closure'] = true; }, 'data'); $job->run(); $this->assertTrue($_SERVER['__queue.closure']); } public function testRunResolvesAndRunsJobClassWithCorrectMethod() { $injector = m::mock('Injector'); $job = new \StudioBonito\SilverStripe\Queue\Jobs\SyncJob($injector, 'Foo@bar', '"data"'); $handler = m::mock('StdClass'); $injector->shouldReceive('get')->once()->with('Foo')->andReturn($handler); $handler->shouldReceive('bar')->once()->with($job, 'data'); $job->run(); } } |