-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #780 from davedevelopment/cater-for-object-type-hints
Cater for object type hints in PHP 7.2
- Loading branch information
Showing
5 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace test\Mockery; | ||
|
||
use Mockery\Adapter\Phpunit\MockeryTestCase; | ||
|
||
/** | ||
* @requires PHP 7.2.0-dev | ||
*/ | ||
class Php72LanguageFeaturesTest extends MockeryTestCase | ||
{ | ||
/** @test */ | ||
public function it_can_mock_a_class_with_an_object_argument_type_hint() | ||
{ | ||
$mock = mock(ArgumentObjectTypeHint::class); | ||
$object = new \stdClass; | ||
$mock->allows()->foo($object); | ||
|
||
$mock->foo($object); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_mock_a_class_with_an_object_return_type_hint() | ||
{ | ||
$mock = spy(ReturnTypeObjectTypeHint::class); | ||
|
||
$object = $mock->foo(); | ||
|
||
$this->assertTrue(is_object($object)); | ||
} | ||
} | ||
|
||
class ArgumentObjectTypeHint | ||
{ | ||
function foo(object $foo) {} | ||
} | ||
|
||
class ReturnTypeObjectTypeHint | ||
{ | ||
function foo(): object {} | ||
} |