usox / hackmock
Mocking framework for hacklang
Installs: 1 711
Dependents: 4
Suggesters: 0
Security: 0
Stars: 7
Watchers: 3
Forks: 7
Open Issues: 2
Language:Hack
Requires
- hhvm: ^4.1
- facebook/fbexpect: ^2.3
- facebook/hack-codegen: ^4
- hhvm/hacktest: ^1.4|^2.0
- hhvm/hsl: ^4.1
- hhvm/type-assert: ^3.2|^4.0
Requires (Dev)
- hhvm/hhast: ^4.1
Suggests
- slack/hack-sql-fake: Database Testing library for Hacklang
README
HackMock
Creating mock objects for hacklang - yes, seriously.
Note
Due to the use of eval
, hackmock may stop working in future hhvm versions.
What works?
- Strict mode
- Creating mocks of interfaces and concrete classes
- Defining basic method expectations (parameter validation, return value definition)
What does not work?
- Everything else, especially rare and/or untested cases involving generics, etc.
use function Usox\HackMock\{mock, prospect}; class SomethingTest extends \Usox\HackMock\HackMock { public function testSomething() { $my_fine_class = mock(SomeInterface::class); prospect($my_fine_class, 'someMethodName') ->once() ->andReturn('some-fine-value'); prospect($my_fine_class, 'someOtherMethodName') ->andThrow(new \Exception('foobar')); } }