/** * Set up test environment. */ public function setUp() { parent::setUp(); $this->link = new \MySQLi('localhost', 'root', '', 'activecollab_jobs_queue_test'); if ($this->link->connect_error) { throw new \RuntimeException('Failed to connect to database. MySQL said: ' . $this->link->connect_error); } $this->connection = new MysqliConnection($this->link); $this->connection->execute('DROP TABLE IF EXISTS `' . MySqlQueue::JOBS_TABLE_NAME . '`'); $queue = new MySqlQueue($this->connection); $queue->onJobFailure(function (Job $job, Exception $reason) { $this->last_failed_job = get_class($job); $this->last_failure_message = $reason->getMessage(); }); $this->dispatcher = new Dispatcher($queue); $this->assertCount(0, $this->dispatcher->getQueue()); }
/** * Set up test environment. */ public function setUp() { parent::setUp(); $this->dispatcher = new Dispatcher(new TestQueue()); $this->assertCount(0, $this->dispatcher->getQueue()); }
/** * Test if run executes immediately. */ public function testRunExecutesImmediately() { $this->assertEquals(1246, $this->dispatcher->execute(new Inc(['number' => 1245]))); $this->assertCount(0, $this->dispatcher->getQueue()); }
/** * Test creation of dispatcher instance with default queue. */ public function testDespatcherWithDefaultQueue() { $dispatcher = new Dispatcher(new TestQueue()); $this->assertInstanceOf('\\ActiveCollab\\JobsQueue\\Queue\\TestQueue', $dispatcher->getQueue()); }