Skip to content

Commit

Permalink
Merge pull request #2 from hmazter/update-test-and-include-laravel-54
Browse files Browse the repository at this point in the history
Update test with integration tests
  • Loading branch information
hmazter authored Jan 28, 2017
2 parents cfe69de + 18d6d65 commit 9f14d5f
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 51 deletions.
9 changes: 3 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@ language: php
php:
- 5.6
- 7.0

matrix:
allow_failures:
- php: 7.0
- 7.1

before_script:
- composer self-update
- composer install --dev
- composer install
- wget https://scrutinizer-ci.com/ocular.phar

script:
- mkdir -p build/logs
- phpunit --coverage-clover build/logs/clover.xml
- vendor/bin/phpunit --coverage-clover build/logs/clover.xml

after_script:
- sh -c "if [ $TRAVIS_PHP_VERSION = '5.6' ]; then php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml; fi"
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
All notable changes to this project will be documented in this file.
This project tries to adhere to [Semantic Versioning](http://semver.org/).

## [0.1.4] - 2017-01-28
### Updated
- Updated tests
- Use ::class style syntax
- Testing against php 7.1

### Other
- Verify with Laravel 5.4

## [0.1.3] - 2015-12-30
### Updated
- Update string replacement in command output in normal output mode to strip; php, artisan, single and double quote
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
}
],
"require": {
"php": ">=5.5.9",
"illuminate/support": "^5.0",
"illuminate/console": "^5.0"
"php": ">=5.6.4",
"illuminate/support": ">=5.0 <5.5",
"illuminate/console": ">=5.0 <5.5"
},
"require-dev": {
"phpunit/phpunit": "^5.0"
"phpunit/phpunit": "^5.0",
"orchestra/testbench": "~3.3"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions src/Console/ListScheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function fire()
{
$events = $this->schedule->events();

if (count($events) == 0) {
if (count($events) === 0) {
$this->info('No tasks scheduled');
return;
}
Expand Down Expand Up @@ -103,7 +103,7 @@ protected function outputTableStyle($events)
}

// remove php binary and std output from the command string
if ($this->output->getVerbosity() == OutputInterface::VERBOSITY_NORMAL) {
if ($this->output->getVerbosity() === OutputInterface::VERBOSITY_NORMAL) {
$command = substr($command, 0, strpos($command, '>'));
$command = trim(str_replace([PHP_BINARY, 'artisan', '\'', '"'], '', $command));
}
Expand Down
14 changes: 3 additions & 11 deletions src/ScheduleListServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,8 @@ class ScheduleListServiceProvider extends ServiceProvider
*/
public function register()
{
$this->commands('Hmazter\LaravelScheduleList\Console\ListScheduler');
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return ['Hmazter\LaravelScheduleList\Console\ListScheduler'];
$this->commands([
Console\ListScheduler::class
]);
}
}
37 changes: 37 additions & 0 deletions tests/Integration/ListSchedulerIntegrationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

use Illuminate\Contracts\Console\Kernel;

class ListSchedulerIntegrationTest extends TestCase
{
/**
* Resolve application Console Kernel implementation.
*
* @param \Illuminate\Foundation\Application $app
*/
protected function resolveApplicationConsoleKernel($app)
{
$app->singleton(Kernel::class, MockConsoleKernel::class);
}

public function testListSchedulerCommand_withTasksAndTableStyle()
{
\Illuminate\Support\Facades\Artisan::call('schedule:list');
$consoleOutput = trim(\Illuminate\Support\Facades\Artisan::output());

self::assertContains('test:command:name', $consoleOutput);
self::assertContains('Description of command', $consoleOutput);
self::assertContains('0 10 * * *', $consoleOutput);
}

public function testListSchedulerCommand_withTasksAndCronStyle()
{
\Illuminate\Support\Facades\Artisan::call('schedule:list', ['--cron' => true]);
$consoleOutput = trim(\Illuminate\Support\Facades\Artisan::output());

self::assertContains('test:command:name', $consoleOutput);
self::assertContains('artisan', $consoleOutput);
self::assertContains('0 10 * * *', $consoleOutput);
self::assertContains((DIRECTORY_SEPARATOR === '\\') ? 'NUL' : '/dev/null', $consoleOutput);
}
}
9 changes: 9 additions & 0 deletions tests/Integration/MockConsoleKernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

class MockConsoleKernel extends \Orchestra\Testbench\Console\Kernel
{
protected function schedule(\Illuminate\Console\Scheduling\Schedule $schedule)
{
$schedule->command('test:command:name')->dailyAt('10:00')->description('Description of command');
}
}
16 changes: 16 additions & 0 deletions tests/Integration/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

class TestCase extends Orchestra\Testbench\TestCase
{
/**
* @param \Illuminate\Foundation\Application $app
*
* @return array
*/
protected function getPackageProviders($app)
{
return [
Hmazter\LaravelScheduleList\ScheduleListServiceProvider::class
];
}
}
28 changes: 0 additions & 28 deletions tests/ListSchedulerTest.php

This file was deleted.

0 comments on commit 9f14d5f

Please sign in to comment.