コード例 #1
0
 function it_should_add_a_gearman_background_job_when_a_job_is_requested($client, JobRequestInterface $jobRequest, $requestSerializer)
 {
     $jobRequest->getName()->willReturn('fooName');
     $requestSerializer->serializeJobRequest($jobRequest)->shouldBeCalled()->willReturn('serializedVersion');
     $client->doBackgroundJob('IceJobBundleGearmanWorker~addDomainJob', 'serializedVersion')->shouldBeCalledTimes(1);
     $this->addJob($jobRequest);
 }
 function it_should_serialize_a_job_request_to_json(JobRequestInterface $jobRequest)
 {
     $jobRequest->getName()->willReturn('fooName');
     $jobRequest->getData()->willReturn(['foo', 'bar']);
     $serialized = $this->serializeJobRequest($jobRequest);
     $serialized->shouldBeString();
     $serialized->shouldBeEqualTo(json_encode(['name' => 'fooName', 'data' => ['foo', 'bar']]));
 }
コード例 #3
0
 function let(WorkerDirectorInterface $workerDirector, JobRequestSerializerInterface $requestSerializer, JobRequestInterface $deserializedJobRequest, WorkerProviderInterface $fooFactory, WorkerInterface $fooWorker, LoggerInterface $logger, EventDispatcherInterface $dispatcher)
 {
     $workerDirector->getWorkerProviderFor('fooName')->willReturn($fooFactory);
     $fooFactory->getWorkerFor('fooName')->willReturn($fooWorker);
     $deserializedJobRequest->getName()->willReturn('fooName');
     $requestSerializer->deserializeJobRequest(Argument::any())->willReturn($deserializedJobRequest);
     $this->beConstructedWith($workerDirector, $requestSerializer);
     //Allow 'good' log calls to be made even if we don't explicitly stub them in the specs
     $logger->debug(Argument::any(), Argument::any())->willReturn(null);
     $logger->info(Argument::any(), Argument::any())->willReturn(null);
     $logger->notice(Argument::any(), Argument::any())->willReturn(null);
 }