mirror of
https://github.com/danog/psalm-plugin-phpunit.git
synced 2024-11-30 04:29:08 +01:00
Improve mocking support
This commit is contained in:
parent
ff427489f0
commit
0c8386711c
@ -12,5 +12,6 @@ class Plugin implements PluginEntryPointInterface
|
||||
{
|
||||
$psalm->addStubFile(__DIR__ . '/stubs/Assert.php');
|
||||
$psalm->addStubFile(__DIR__ . '/stubs/TestCase.php');
|
||||
$psalm->addStubFile(__DIR__ . '/stubs/MockBuilder.php');
|
||||
}
|
||||
}
|
||||
|
33
stubs/MockBuilder.php
Normal file
33
stubs/MockBuilder.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace PHPUnit\Framework\MockObject;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
class MockBuilder
|
||||
{
|
||||
/**
|
||||
* @template-typeof T $type
|
||||
* @param TestCase $testCase
|
||||
* @param class-string $type
|
||||
*/
|
||||
public function __construct(TestCase $testCase, $type) {}
|
||||
|
||||
/**
|
||||
* Creates a mock object using a fluent interface.
|
||||
*
|
||||
* @return MockObject&T
|
||||
*/
|
||||
public function getMock() {}
|
||||
|
||||
/**
|
||||
* Specifies the subset of methods to mock. Default is to mock none of them.
|
||||
*
|
||||
* @param array|null $methods
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setMethods(array $methods = null) {}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\MockObject\MockBuilder;
|
||||
|
||||
abstract class TestCase extends Assert implements Test, SelfDescribing
|
||||
{
|
||||
@ -13,4 +13,15 @@ abstract class TestCase extends Assert implements Test, SelfDescribing
|
||||
* @return MockObject&T
|
||||
*/
|
||||
public function createMock($class) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a builder object to create mock objects using a fluent interface.
|
||||
*
|
||||
* @template T
|
||||
* @template-typeof T $className
|
||||
* @param class-string $className
|
||||
*
|
||||
* @return MockBuilder<T>
|
||||
*/
|
||||
public function getMockBuilder(string $className) {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user