New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix PHP Doc Comments #1410
base: 1.6.x
Are you sure you want to change the base?
Fix PHP Doc Comments #1410
Conversation
Mockery:mock
method phpdocs
Mockery:mock
method phpdocsMockery:mock
method phpdocs
Somehow related, I think the phpdoc in $mock = Mockery::namedMock('AnotherName', MyClass::class); |
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 1.6.x #1410 +/- ##
============================================
- Coverage 77.85% 77.65% -0.20%
- Complexity 1022 1026 +4
============================================
Files 76 76
Lines 2596 2623 +27
============================================
+ Hits 2021 2037 +16
- Misses 575 586 +11
|
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
f17dbdd
to
1c67601
Compare
there are many ways to create a mock, this list may not be complete. $mock = \Mockery::mock();
$mock = \Mockery::mock(MyClass::class);
$mock = \Mockery::mock(MyClass::class, function ($mock) {
$mock->shouldAllowMockingProtectedMethods();
});
$mock = \Mockery::mock(array('pi' => 3.1416, 'itWorks' => true));
$this->assertEquals(3.1416, $mock->pi());
$mock = \Mockery::mock('MyClass, MyInterface');
$mock = \Mockery::mock('MyClass', 'MyInterface, OtherInterface');
// <!-- runtime partial test doubles, -->
class Foo {
function foo() {
return 123;
}
function bar() {
return $this->foo();
}
}
$foo = mock(Foo::class)->makePartial();
$foo->foo(); // int(123);
// <!-- generated partial test doubles, and -->
$mock = \Mockery::mock('MyClass[method]', [param]);
// <!-- proxied partial test doubles. -->
$mock = \Mockery::mock(new MyClass);
// <!-- aliasing, -->
$mock = \Mockery::mock('alias:MyClass');
// <!-- and overloading. -->
$mock = \Mockery::mock('overload:MyClass');
// <!-- named mocks, -->
$mock = \Mockery::namedMock('MyClassName', 'DateTime');
// <!-- with constructor arguments, -->
$mock = \Mockery::mock('MyClass', [$constructorArg1, $constructorArg2]);
$mock = \Mockery::mock('MyClass', 'MyInterface', [$constructorArg1, $constructorArg2]);
// <!-- There’s also a shorthand way of setting up method call expectations and their return values: -->
$mock = \Mockery::mock('MyClass', ['name_of_method_1' => 'return value 1', 'name_of_method_2' => 'return value 2']);
// <!-- In the next example, the foo() and bar() methods of MyClass will be mocked but no other MyClass methods are touched.
// We will need to define expectations for the foo() and bar() methods to dictate their mocked behaviour. -->
$mock = \Mockery::mock('MyClass[foo,bar]');
// <!-- pass in constructor arguments since unmocked methods may rely on those -->
$mock = \Mockery::mock('MyNamespace\MyClass[foo]', array($arg1, $arg2)); we’ll add tests using each syntax, including |
Everything that can be done with |
Related issue:
Mockery::mock()
/spy()
phpdoc (= phpstan errors) #1400Steps to reproduce:
When installing the latest:
mockery/mock:1.6.11
in project dependencies, the related issue persists when Closure used.Example code that generates the phpstan issue:
phpstan
error:Description
This pull request includes a change to the
mock
function in theMockery.php
file. The change expands the type of the$args
parameter to also includeClosure
along with the existing types.This change allows
Closure
objects to be passed as arguments to themock
function, which fixes mentioned phpstan error.