-
Notifications
You must be signed in to change notification settings - Fork 3
/
BuilderExposeTest.php
89 lines (81 loc) · 2.52 KB
/
BuilderExposeTest.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
namespace Concise\Mock;
/**
* @group mocking
*/
class BuilderExposeTest extends AbstractBuilderTestCase
{
protected function youCannotExposeAMethodOnAMockThatIsNotNice($type)
{
switch ($type) {
case self::MOCK_INTERFACE:
case self::MOCK_CLASS:
case self::MOCK_ABSTRACT_CLASS:
$this->expectFailure("You cannot expose a method on a mock that is not nice.");
}
}
/**
* @group #189
* @dataProvider allBuilders
*/
public function testExposeASingleMethod(MockBuilder $builder, $type)
{
$this->youCannotExposeAMethodOnAMockThatIsNotNice($type);
$mock = $builder->expose('mySecretMethod')
->get();
$this->assert($mock->myMethod(), equals, 'abc');
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage does not exist.
* @group #189
* @dataProvider allBuilders
*/
public function testAnExceptionIsThrownIfTheMethodDoesNotExist(MockBuilder $builder, $type)
{
$this->youCannotExposeAMethodOnAMockThatIsNotNice($type);
$builder->expose('baz')
->get();
}
/**
* @group #189
* @dataProvider allBuilders
*/
public function testExposeTwoMethodsWithSeparateParameters(MockBuilder $builder, $type)
{
$this->youCannotExposeAMethodOnAMockThatIsNotNice($type);
$mock = $builder->expose('myMethod', 'mySecondMethod')
->get();
$this->assert($mock->mySecondMethod(), equals, 'bar');
}
/**
* @group #189
* @dataProvider allBuilders
*/
public function testExposeTwoMethodsByCallingExposeTwice(MockBuilder $builder, $type)
{
$this->youCannotExposeAMethodOnAMockThatIsNotNice($type);
$mock = $builder->expose('myMethod')->expose('mySecondMethod')
->get();
$this->assert($mock->myMethod(), equals, 'abc');
}
/**
* @group #189
* @dataProvider allBuilders
*/
public function testExposeTwoMethodsWithArraySyntax(MockBuilder $builder, $type)
{
$this->youCannotExposeAMethodOnAMockThatIsNotNice($type);
$mock = $builder->expose(array('myMethod', 'mySecondMethod'))
->get();
$this->assert($mock->mySecondMethod(), equals, 'bar');
}
/**
* @group #189
* @dataProvider allBuilders
*/
public function testExposeAllCanBeChained(MockBuilder $builder)
{
$this->assert($builder->exposeAll(), is_the_same_as, $builder);
}
}