@@ -57,7 +57,7 @@ public function testGetMockForAbstractClassStubbingAbstractClass()
57
57
/**
58
58
* @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
59
59
*/
60
- public function testGetMockForAbstractClassWithNonexistentMethods ()
60
+ public function testGetMockForAbstractClassWithNonExistentMethods ()
61
61
{
62
62
$ mock = $ this ->generator ->getMockForAbstractClass (
63
63
'AbstractMockTestClass ' , array (), '' , true ,
@@ -68,6 +68,21 @@ public function testGetMockForAbstractClassWithNonexistentMethods()
68
68
$ this ->assertTrue (method_exists ($ mock , 'doSomething ' ));
69
69
}
70
70
71
+ /**
72
+ * @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
73
+ */
74
+ public function testGetMockForAbstractClassShouldCreateStubsOnlyForAbstractMethodWhenNoMethodsWereInformed ()
75
+ {
76
+ $ mock = $ this ->generator ->getMockForAbstractClass ('AbstractMockTestClass ' );
77
+
78
+ $ mock ->expects ($ this ->any ())
79
+ ->method ('doSomething ' )
80
+ ->willReturn ('testing ' );
81
+
82
+ $ this ->assertEquals ('testing ' , $ mock ->doSomething ());
83
+ $ this ->assertEquals (1 , $ mock ->returnAnything ());
84
+ }
85
+
71
86
/**
72
87
* @dataProvider getMockForAbstractClassExpectsInvalidArgumentExceptionDataprovider
73
88
* @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
@@ -98,9 +113,27 @@ public static function getMockForAbstractClassExpectsInvalidArgumentExceptionDat
98
113
);
99
114
}
100
115
116
+ /**
117
+ * @covers PHPUnit_Framework_MockObject_Generator::getMockForTrait
118
+ * @requires PHP 5.4.0
119
+ */
120
+ public function testGetMockForTraitWithNonExistentMethodsAndNonAbstractMethods ()
121
+ {
122
+ $ mock = $ this ->generator ->getMockForTrait (
123
+ 'AbstractTrait ' , array (), '' , true ,
124
+ true , true , array ('nonexistentMethod ' )
125
+ );
126
+
127
+ $ this ->assertTrue (method_exists ($ mock , 'nonexistentMethod ' ));
128
+ $ this ->assertTrue (method_exists ($ mock , 'doSomething ' ));
129
+ $ this ->assertTrue ($ mock ->mockableMethod ());
130
+ $ this ->assertTrue ($ mock ->anotherMockableMethod ());
131
+ }
132
+
101
133
/**
102
134
* @dataProvider getMockForTraitExpectsInvalidArgumentExceptionDataprovider
103
135
* @covers PHPUnit_Framework_MockObject_Generator::getMockForTrait
136
+ * @requires PHP 5.4.0
104
137
* @expectedException PHPUnit_Framework_Exception
105
138
*/
106
139
public function testGetMockForTraitExpectingInvalidArgumentException ($ traitName , $ mockClassName )
0 commit comments