-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathBehaviorTest.php
42 lines (35 loc) · 1.07 KB
/
BehaviorTest.php
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
<?php
namespace Tests;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;
use stdClass;
use Zumba\Swivel\Behavior;
class BehaviorTest extends TestCase
{
public function testExecute()
{
$mock = $this->getMockBuilder(stdClass::class)
->addMethods(['callback'])
->getMock();
$mock->expects($this->once())
->method('callback')
->with('a', 'b')
->will($this->returnValue(true));
$behavior = new Behavior('a', [$mock, 'callback']);
$this->assertTrue($behavior->execute(['a', 'b']));
}
public function testExecuteWithLogger()
{
$logger = $this->getMockBuilder(NullLogger::class)
->getMock();
$behavior = new Behavior('a', fn() => null);
$behavior->setLogger($logger);
$logger->expects($this->once())
->method('debug')
->with($this->isType('string'), $this->logicalAnd(
$this->arrayHasKey('slug'),
$this->arrayHasKey('args')
));
$behavior->execute();
}
}