When run in Client mode it will allow adding new jobs to the Queue. When run in worker mode it will execute jobs on the Queue. Worker mode also allows adding new jobs to the queue just like Mlient mode.
Exemplo n.º 1
0
function wp_gears_runner()
{
    wp_gears_autoloader();
    $plugin = \WpGears\Plugin::get_instance();
    $plugin->enable();
    return $plugin->run();
}
Exemplo n.º 2
0
function wp_async_task_init()
{
    wp_gears_autoloader();
    $plugin = \WpGears\Plugin::get_instance();
    $plugin->enable();
    $GLOBALS['wp_async_task'] = $plugin;
}
Exemplo n.º 3
0
 function test_it_can_add_job_to_client_object()
 {
     $mock = \Mockery::mock()->shouldReceive('register')->atMost(1)->shouldReceive('addServer')->atMost(1)->andReturn(true)->shouldReceive('add')->with('action_b', array(1, 2, 3), 'low')->once()->andReturn(true)->getMock();
     $plugin = \WpGears\Plugin::get_instance();
     $plugin->config_prefix = 'C' . uniqid();
     $plugin->client = $mock;
     $actual = wp_async_task_add('action_b', array(1, 2, 3), 'low');
     $this->assertTrue($actual);
 }
Exemplo n.º 4
0
 function test_it_will_execute_a_job_on_run()
 {
     $mock = \Mockery::mock()->shouldReceive('register')->andReturn(true)->shouldReceive('work')->with()->once()->andReturn(true)->getMock();
     $plugin = \WpGears\Plugin::get_instance();
     $plugin->config_prefix = 'B' . uniqid();
     $plugin->worker = $mock;
     $actual = wp_gears_runner();
     $this->assertEquals(0, $actual);
 }