Skip to content

Commit

Permalink
Test Worker class
Browse files Browse the repository at this point in the history
  • Loading branch information
A5hleyRich committed Oct 9, 2017
1 parent 10745e6 commit 17d1b1c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/TestWorker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

use PHPUnit\Framework\TestCase;
use WP_Queue\Connections\ConnectionInterface;
use WP_Queue\Job;
use WP_Queue\Worker;

class TestWorker extends TestCase {

public function setUp() {
WP_Mock::setUp();
}

public function tearDown() {
WP_Mock::tearDown();
}

public function test_process_success() {
$connection = Mockery::spy( ConnectionInterface::class );
$job = Mockery::spy( Job::class );
$connection->shouldReceive( 'pop' )->once()->andReturn( $job );

$worker = new Worker( $connection );
$this->assertTrue( $worker->process() );
}

public function test_process_fail() {
$connection = Mockery::spy( ConnectionInterface::class );
$job = Mockery::spy( Job::class );
$connection->shouldReceive( 'pop' )->once()->andReturn( false );

$worker = new Worker( $connection );
$this->assertFalse( $worker->process() );
}
}

0 comments on commit 17d1b1c

Please sign in to comment.