@@ -54,6 +54,35 @@ public function testGetMockForAbstractClassStubbingAbstractClass()
5454 $ this ->assertTrue (method_exists ($ mock , 'doSomething ' ));
5555 }
5656
57+ /**
58+ * @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
59+ */
60+ public function testGetMockForAbstractClassWithNonExistentMethods ()
61+ {
62+ $ mock = $ this ->generator ->getMockForAbstractClass (
63+ 'AbstractMockTestClass ' , array (), '' , true ,
64+ true , true , array ('nonexistentMethod ' )
65+ );
66+
67+ $ this ->assertTrue (method_exists ($ mock , 'nonexistentMethod ' ));
68+ $ this ->assertTrue (method_exists ($ mock , 'doSomething ' ));
69+ }
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+
5786 /**
5887 * @dataProvider getMockForAbstractClassExpectsInvalidArgumentExceptionDataprovider
5988 * @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
@@ -84,9 +113,27 @@ public static function getMockForAbstractClassExpectsInvalidArgumentExceptionDat
84113 );
85114 }
86115
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+
87133 /**
88134 * @dataProvider getMockForTraitExpectsInvalidArgumentExceptionDataprovider
89135 * @covers PHPUnit_Framework_MockObject_Generator::getMockForTrait
136+ * @requires PHP 5.4.0
90137 * @expectedException PHPUnit_Framework_Exception
91138 */
92139 public function testGetMockForTraitExpectingInvalidArgumentException ($ traitName , $ mockClassName )
0 commit comments