forked from codeigniter4/tasks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMockTest.php
More file actions
54 lines (41 loc) · 1.15 KB
/
MockTest.php
File metadata and controls
54 lines (41 loc) · 1.15 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
51
52
53
54
<?php
declare(strict_types=1);
/**
* This file is part of CodeIgniter Tasks.
*
* (c) CodeIgniter Foundation <[email protected]>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace CodeIgniter\Tasks\Test;
use Tests\Support\TasksTestCase;
/**
* @internal
*/
final class MockTest extends TasksTestCase
{
private MockScheduler $scheduler;
protected function setUp(): void
{
parent::setUp();
$this->scheduler = new MockScheduler();
}
public function testMockSchedulerCreatesMockTasks()
{
$result = $this->scheduler->command('foo:bar');
$this->assertInstanceOf(MockTask::class, $result);
}
public function testMockTaskPreventsRun()
{
$task = new MockTask('command', 'tasks:test');
$task->run();
$this->assertArrayNotHasKey('command_tasks_test_did_run', $_SESSION);
}
public function testMockTaskSetsSession()
{
$task = new MockTask('command', 'foo:bar');
$task->run();
$this->assertSame(['command', 'foo:bar'], $_SESSION['tasks_cache']);
}
}