push(Job::class, ['data' => 100]); $this->assertNotEmpty($id); $this->assertFileExists(Job::JOB_FILE); $data = json_decode(file_get_contents(Job::JOB_FILE), true); $this->assertSame($id, $data['id']); $this->assertSame(100, $data['data']); } public function testLocalDelayed(): void { $c = new ContainerRegistry(new Container()); $jobs = new ShortCircuit($c, $c); $t = microtime(true); $id = $jobs->push(Job::class, ['data' => 100], Options::delayed(1)); $this->assertTrue(microtime(true) - $t >= 1); $this->assertNotEmpty($id); $this->assertFileExists(Job::JOB_FILE); $data = json_decode(file_get_contents(Job::JOB_FILE), true); $this->assertSame($id, $data['id']); $this->assertSame(100, $data['data']); } /** * @expectedException \Spiral\Jobs\Exception\JobException */ public function testError(): void { $c = new ContainerRegistry(new Container()); $jobs = new ShortCircuit($c, $c); $jobs->push(ErrorJob::class); } public function testLocalDelay(): void { $c = new ContainerRegistry(new Container()); $jobs = new ShortCircuit($c, $c); $id = $jobs->push(Job::class, ['data' => 100], Options::delayed(1)); $this->assertNotEmpty($id); $this->assertFileExists(Job::JOB_FILE); $data = json_decode(file_get_contents(Job::JOB_FILE), true); $this->assertSame($id, $data['id']); $this->assertSame(100, $data['data']); } }