Skip to content

Commit

Permalink
Merge pull request #653 from driesvints/fix-6.0-build
Browse files Browse the repository at this point in the history
[3.0] Make sure 6.0 build passes
  • Loading branch information
driesvints authored Aug 23, 2019
2 parents 30528b0 + e51da53 commit ce216f1
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ composer.lock
Thumbs.db
phpunit.xml
/.idea
.phpunit.result.cache
9 changes: 6 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ env:
matrix:
- LARAVEL=5.7.*
- LARAVEL=5.8.*
- LARAVEL=dev-master
- LARAVEL=^6.0
- LARAVEL=^7.0

matrix:
fast_finish: true
exclude:
- php: 7.1
env: LARAVEL=dev-master
env: LARAVEL=^6.0
- php: 7.1
env: LARAVEL=^7.0
allow_failures:
- env: LARAVEL=dev-master
- env: LARAVEL=^7.0

before_install:
- phpenv config-rm xdebug.ini || true
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
"ext-pcntl": "*",
"ext-posix": "*",
"cakephp/chronos": "^1.0",
"illuminate/contracts": "~5.7.0|~5.8.0|^6.0",
"illuminate/queue": "~5.7.0|~5.8.0|^6.0",
"illuminate/support": "~5.7.0|~5.8.0|^6.0",
"illuminate/contracts": "~5.7.0|~5.8.0|^6.0|^7.0",
"illuminate/queue": "~5.7.0|~5.8.0|^6.0|^7.0",
"illuminate/support": "~5.7.0|~5.8.0|^6.0|^7.0",
"predis/predis": "^1.1",
"ramsey/uuid": "^3.5",
"symfony/process": "^4.2",
"symfony/debug": "^4.2"
},
"require-dev": {
"mockery/mockery": "^1.0",
"orchestra/testbench": "^3.7",
"phpunit/phpunit": "^7.0"
"orchestra/testbench": "^3.7|^4.0|^5.0",
"phpunit/phpunit": "^7.0|^8.0"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 4 additions & 0 deletions src/HorizonServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ public function register()
define('HORIZON_PATH', realpath(__DIR__.'/../'));
}

$this->app->bind(Console\WorkCommand::class, function ($app) {
return new Console\WorkCommand($app['queue.worker'], $app['cache.store']);
});

$this->configure();
$this->offerPublishing();
$this->registerServices();
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Laravel\Horizon\Horizon;
use Laravel\Horizon\Tests\IntegrationTest;
use Laravel\Horizon\Http\Middleware\Authenticate;
use Symfony\Component\HttpKernel\Exception\HttpException;

class AuthTest extends IntegrationTest
{
Expand Down Expand Up @@ -40,11 +41,10 @@ function ($value) {
$this->assertSame('response', $response);
}

/**
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
*/
public function test_authentication_middleware_responds_with_403_on_failure()
{
$this->expectException(HttpException::class);

Horizon::auth(function () {
return false;
});
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/MasterSupervisorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Laravel\Horizon\Tests\Feature;

use Mockery;
use Exception;
use Laravel\Horizon\PhpBinary;
use Illuminate\Support\Facades\Redis;
use Laravel\Horizon\MasterSupervisor;
Expand Down Expand Up @@ -166,11 +167,10 @@ public function test_master_process_information_is_persisted()
$this->assertSame('paused', $masterRecord->status);
}

/**
* @expectedException \Exception
*/
public function test_master_process_should_not_allow_duplicate_master_process_on_same_machine()
{
$this->expectException(Exception::class);

$master = new MasterSupervisor;
$master->working = true;
$master2 = new MasterSupervisor;
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/RedisJobRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public function test_it_saves_microseconds_as_a_float_and_disregards_the_locale(

$result = $repository->getRecent()[0];

$this->assertNotContains(',', $result->reserved_at);
$this->assertStringNotContainsString(',', $result->reserved_at);
}
}
6 changes: 3 additions & 3 deletions tests/Feature/SupervisorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Laravel\Horizon\Tests\Feature;

use Mockery;
use Exception;
use Cake\Chronos\Chronos;
use Laravel\Horizon\PhpBinary;
use Laravel\Horizon\AutoScaler;
Expand Down Expand Up @@ -420,11 +421,10 @@ public function test_auto_scaler_is_called_on_loop_when_auto_scaling()
$supervisor->loop();
}

/**
* @expectedException \Exception
*/
public function test_supervisor_with_duplicate_name_cant_be_started()
{
$this->expectException(Exception::class);

$options = $this->options();
$this->supervisor = $supervisor = new Supervisor($options);
$supervisor->persist();
Expand Down
4 changes: 2 additions & 2 deletions tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ protected function setUp(): void
*/
protected function tearDown(): void
{
parent::tearDown();

Redis::flushall();
WorkerCommandString::reset();
SupervisorCommandString::reset();
Horizon::$authUsing = null;

parent::tearDown();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/UnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

abstract class UnitTest extends TestCase
{
public function tearDown()
protected function tearDown(): void
{
Mockery::close();
}
Expand Down
19 changes: 14 additions & 5 deletions tests/worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
require __DIR__.'/../vendor/autoload.php';

use Illuminate\Queue\Worker;
use Illuminate\Queue\QueueManager;
use Illuminate\Queue\WorkerOptions;
use Orchestra\Testbench\Traits\CreatesApplication;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Debug\ExceptionHandler;
use Orchestra\Testbench\Concerns\CreatesApplication;

$appLoader = new class {
use CreatesApplication;
Expand All @@ -25,10 +28,16 @@ protected function getEnvironmentSetUp($app)
// Configure the application...
$app = $appLoader->createApplication();
$app->register(Laravel\Horizon\HorizonServiceProvider::class);
$app['config']->set('queue.default', 'redis');

// Create the worker...
$worker = app(Worker::class);
$app->make('config')->set('queue.default', 'redis');

$worker = new Worker(
$app->make(QueueManager::class),
$app->make(Dispatcher::class),
$app->make(ExceptionHandler::class),
function () use ($app) {
return $app->isDownForMaintenance();
}
);

// Pause the worker if needed...
if (in_array('--paused', $_SERVER['argv'])) {
Expand Down

0 comments on commit ce216f1

Please sign in to comment.