forked from rossedman/teamwork
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathObjectTest.php
71 lines (55 loc) · 1.52 KB
/
ObjectTest.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
use Mockery as m;
class ObjectTest extends PHPUnit_Framework_TestCase {
protected $object;
public function setUp()
{
parent::setup();
$request = m::mock('Rossedman\Teamwork\Contracts\RequestableInterface');
$this->object = new ObjectStub($request);
}
public function tearDown()
{
m::close();
}
/**
* @group object
*/
public function test_it_has_client_injected()
{
$this->assertObjectHasAttribute('client', $this->object);
}
/**
* @group object
*/
public function test_if_arguments_are_valid()
{
$args = ['testArg' => 2, 'testArg2' => 3];
$accepted = ['testArg', 'testArg2'];
$return = $this->object->valid_args($args, $accepted);
$this->assertTrue($return);
}
/**
* @group object
*/
public function test_if_arguments_are_null()
{
$return = $this->object->valid_args(null, []);
$this->assertNull($return);
}
/**
* @group object
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage This call only accepts these arguments: testArg | testArg2
*/
public function test_if_arguments_do_not_match_exception_is_thrown()
{
$this->object->valid_args(['whatever' => 1], ['testArg', 'testArg2']);
}
}
class ObjectStub extends \Rossedman\Teamwork\AbstractObject {
public function valid_args($args, $accepted)
{
return $this->areArgumentsValid($args, $accepted);
}
}