forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsoleEventSchedulerTest.php
More file actions
50 lines (42 loc) · 2.06 KB
/
ConsoleEventSchedulerTest.php
File metadata and controls
50 lines (42 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
use Mockery as m;
use Illuminate\Console\Scheduling\Schedule;
class ConsoleEventSchedulerTest extends PHPUnit_Framework_TestCase
{
public function tearDown()
{
m::close();
}
public function testExecCreatesNewCommand()
{
$escape = '\\' === DIRECTORY_SEPARATOR ? '"' : '\'';
$escapeReal = '\\' === DIRECTORY_SEPARATOR ? '\\"' : '"';
$schedule = new Schedule;
$schedule->exec('path/to/command');
$schedule->exec('path/to/command -f --foo="bar"');
$schedule->exec('path/to/command', ['-f']);
$schedule->exec('path/to/command', ['--foo' => 'bar']);
$schedule->exec('path/to/command', ['-f', '--foo' => 'bar']);
$schedule->exec('path/to/command', ['--title' => 'A "real" test']);
$events = $schedule->events();
$this->assertEquals('path/to/command', $events[0]->command);
$this->assertEquals('path/to/command -f --foo="bar"', $events[1]->command);
$this->assertEquals('path/to/command -f', $events[2]->command);
$this->assertEquals("path/to/command --foo={$escape}bar{$escape}", $events[3]->command);
$this->assertEquals("path/to/command -f --foo={$escape}bar{$escape}", $events[4]->command);
$this->assertEquals("path/to/command --title={$escape}A {$escapeReal}real{$escapeReal} test{$escape}", $events[5]->command);
}
public function testCommandCreatesNewArtisanCommand()
{
$escape = '\\' === DIRECTORY_SEPARATOR ? '"' : '\'';
$schedule = new Schedule;
$schedule->command('queue:listen');
$schedule->command('queue:listen --tries=3');
$schedule->command('queue:listen', ['--tries' => 3]);
$events = $schedule->events();
$binary = $escape.PHP_BINARY.$escape.(defined('HHVM_VERSION') ? ' --php' : '');
$this->assertEquals($binary.' artisan queue:listen', $events[0]->command);
$this->assertEquals($binary.' artisan queue:listen --tries=3', $events[1]->command);
$this->assertEquals($binary.' artisan queue:listen --tries=3', $events[2]->command);
}
}