| @@ 70-86 (lines=17) @@ | ||
| 67 | ); | |
| 68 | } | |
| 69 | ||
| 70 | public function testErrorRun() | |
| 71 |     { | |
| 72 | $this->workerManager->addWorker($this->worker); | |
| 73 | // Create a job | |
| 74 | $this->worker->later()->exceptionThrown(20); | |
| 75 | ||
| 76 | // run the job | |
| 77 | $job = $this->workerManager->run(); | |
| 78 | ||
| 79 | self::assertNotNull($job, 'Job object should not be null'); | |
| 80 | self::assertEquals( | |
| 81 | BaseJob::STATUS_EXCEPTION, | |
| 82 | $job->getStatus(), | |
| 83 | 'Worker run should be not successful' | |
| 84 | ); | |
| 85 | self::assertNotEmpty($job->getMessage(), 'Error message should not be empty'); | |
| 86 | } | |
| 87 | ||
| 88 | public function testRunJob() | |
| 89 |     { | |
| @@ 88-107 (lines=20) @@ | ||
| 85 | self::assertNotEmpty($job->getMessage(), 'Error message should not be empty'); | |
| 86 | } | |
| 87 | ||
| 88 | public function testRunJob() | |
| 89 |     { | |
| 90 | $this->workerManager->addWorker($this->worker); | |
| 91 | ||
| 92 | // Create a job | |
| 93 | $job = $this->worker->later()->fibonacciFile(20); | |
| 94 | $job = $this->workerManager->runJob($job); | |
| 95 | ||
| 96 | self::assertEquals( | |
| 97 | BaseJob::STATUS_SUCCESS, | |
| 98 | $job->getStatus(), | |
| 99 | 'Worker run should be successful' | |
| 100 | ); | |
| 101 | ||
| 102 | self::assertEquals( | |
| 103 | '20: 6765', | |
| 104 | file_get_contents($this->worker->getFilename()), | |
| 105 | 'Result of fibonacciFile() must match' | |
| 106 | ); | |
| 107 | } | |
| 108 | } | |
| 109 | ||