Crunz\Schedule::events PHP Method

events() public method

Get or set the events of the schedule object
public events ( array $events = null ) : array
$events array
return array
    public function events(array $events = null)
    {
        if (!is_null($events)) {
            return $this->events = $events;
        }
        return $this->events;
    }

Usage Example

Beispiel #1
0
 public function testRun()
 {
     $escape = '\\' === DIRECTORY_SEPARATOR ? '"' : '\'';
     $escapeReal = '\\' === DIRECTORY_SEPARATOR ? '\\"' : '"';
     $schedule = new Schedule();
     $schedule->run('path/to/command');
     $schedule->run('path/to/command -f --foo="bar"');
     $schedule->run('path/to/command', ['-f']);
     $schedule->run('path/to/command', ['--foo' => 'bar']);
     $schedule->run('path/to/command', ['-f', '--foo' => 'bar']);
     $schedule->run('path/to/command', ['--title' => 'A "real" test']);
     $events = $schedule->events();
     $this->assertEquals('path/to/command', $events[0]->getCommand());
     $this->assertEquals('path/to/command -f --foo="bar"', $events[1]->getCommand());
     $this->assertEquals('path/to/command -f', $events[2]->getCommand());
     $this->assertEquals("path/to/command --foo={$escape}bar{$escape}", $events[3]->getCommand());
     $this->assertEquals("path/to/command -f --foo={$escape}bar{$escape}", $events[4]->getCommand());
     $this->assertEquals("path/to/command --title={$escape}A {$escapeReal}real{$escapeReal} test{$escape}", $events[5]->getCommand());
 }