Skip to content

Commit c74f57c

Browse files
committed
Fix phpunit methods
1 parent d3cbdb1 commit c74f57c

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final class CalculatorTest extends TestCase
3131
$arguments = [[1,2,3], [4,5,6]]
3232
$responses = [6, 120]
3333

34-
$mock->expects(self::exactly(count($arguments)))->method('multiply')
34+
$mock->expects($this->exactly(count($arguments)))->method('multiply')
3535
->withConsecutive(...$arguments)
3636
->willReturnOnConsecutiveCalls(...$responses);
3737

@@ -57,7 +57,7 @@ final class CalculatorTest extends TestCase
5757
$arguments = [[1,2,3], [4,5,6]]
5858
$responses = [6, 120]
5959

60-
$mock->expects(self::exactly(count($arguments)))->method('multiply')
60+
$mock->expects($this->exactly(count($arguments)))->method('multiply')
6161
->will(self::withConsecutive($arguments, $responses));
6262

6363
// ... test
@@ -86,7 +86,7 @@ or add requirement to your `composer.json`
8686
Validate arguments and responses:
8787

8888
```php
89-
$mock->expects(self::exactly(2))->method('example')
89+
$mock->expects($this->exactly(2))->method('example')
9090
->will(self::withConsecutive(
9191
arguments: [
9292
[1, 2, 0.1],
@@ -105,7 +105,7 @@ self::assertFalse($mock->example(2, 3, 0.01));
105105
Optional responses:
106106

107107
```php
108-
$mock->expects(self::exactly(2))->method('example')
108+
$mock->expects($this->exactly(2))->method('example')
109109
->will(self::withConsecutive(
110110
arguments: [
111111
[1, 2, 0.1],
@@ -120,7 +120,7 @@ $mock->example(2, 3, 0.01);
120120
Simplification for same response for each call
121121

122122
```php
123-
$mock->expects(self::exactly(2))->method('example')
123+
$mock->expects($this->exactly(2))->method('example')
124124
->will(self::withConsecutive(
125125
arguments: [
126126
[1, 2, 0.1],
@@ -136,7 +136,7 @@ self::assertTrue($mock->example(2, 3, 0.01));
136136
Supports throwing exceptions:
137137

138138
```php
139-
$mock->expects(self::exactly(2))->method('example')
139+
$mock->expects($this->exactly(2))->method('example')
140140
->will(self::withConsecutive(
141141
arguments: [
142142
[1, 2, 0.1],
@@ -199,7 +199,7 @@ The MIT License (MIT). Please see [License File][link-licence] for more informat
199199
[ico-code-quality]: https://img.shields.io/scrutinizer/g/inspirum/phpunit-extension.svg?style=flat-square
200200
[ico-packagist-stable]: https://img.shields.io/packagist/v/inspirum/phpunit-extension.svg?style=flat-square&colorB=blue
201201
[ico-packagist-download]: https://img.shields.io/packagist/dt/inspirum/phpunit-extension.svg?style=flat-square&colorB=blue
202-
[ico-phpstan]: https://img.shields.io/badge/style-level%209-brightgreen.svg?style=flat-square&label=phpstan
202+
[ico-phpstan]: https://img.shields.io/badge/style-level%2010-brightgreen.svg?style=flat-square&label=phpstan
203203

204204
[link-author]: https://github.com/inspirum
205205
[link-contributors]: https://github.com/inspirum/phpunit-extension/contributors

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"@phpcs"
6565
],
6666
"style:phpstan": [
67-
"@phpstan -l 9"
67+
"@phpstan"
6868
],
6969
"style:check": [
7070
"@style:phpcs",

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
includes:
22
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
33
parameters:
4-
level: 9
4+
level: 10
55
paths:
66
- src
77
- tests

tests/BaseWithConsecutiveTestCase.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ abstract protected static function assert(array $arguments, mixed $responses = n
3636
public function testSingle(): void
3737
{
3838
$this->mock
39-
->expects(self::exactly(3))
39+
->expects($this->exactly(3))
4040
->method('single')
4141
->will(static::assert([
4242
['1'],
@@ -52,15 +52,15 @@ public function testSingle(): void
5252
public function testEmpty(): void
5353
{
5454
$this->mock
55-
->expects(self::exactly(0))
55+
->expects($this->exactly(0))
5656
->method('single')
5757
->will(static::assert([], true));
5858
}
5959

6060
public function testSingleResponse(): void
6161
{
6262
$this->mock
63-
->expects(self::exactly(3))
63+
->expects($this->exactly(3))
6464
->method('single')
6565
->will(static::assert([
6666
['1'],
@@ -80,7 +80,7 @@ public function testSingleResponse(): void
8080
public function testSingleSameResponse(): void
8181
{
8282
$this->mock
83-
->expects(self::exactly(3))
83+
->expects($this->exactly(3))
8484
->method('single')
8585
->will(static::assert(
8686
[
@@ -98,11 +98,11 @@ public function testSingleSameResponse(): void
9898

9999
public function testSingleFailResponseLength(): void
100100
{
101-
self::expectException(LengthException::class);
102-
self::expectExceptionMessage('Arguments and responses arrays must be same length');
101+
$this->expectException(LengthException::class);
102+
$this->expectExceptionMessage('Arguments and responses arrays must be same length');
103103

104104
$this->mock
105-
->expects(self::any())
105+
->expects($this->any())
106106
->method('single')
107107
->will(static::assert([
108108
['1'],
@@ -115,11 +115,11 @@ public function testSingleFailResponseLength(): void
115115

116116
public function testSingleExceptionResponse(): void
117117
{
118-
self::expectException(RuntimeException::class);
119-
self::expectExceptionMessage('Custom error');
118+
$this->expectException(RuntimeException::class);
119+
$this->expectExceptionMessage('Custom error');
120120

121121
$this->mock
122-
->expects(self::any())
122+
->expects($this->any())
123123
->method('single')
124124
->will(static::assert([
125125
['1'],
@@ -138,7 +138,7 @@ public function testSingleExceptionResponse(): void
138138
public function testSingleStubResponse(): void
139139
{
140140
$this->mock
141-
->expects(self::any())
141+
->expects($this->any())
142142
->method('single')
143143
->will(static::assert([
144144
['1'],
@@ -158,7 +158,7 @@ public function testSingleStubResponse(): void
158158
public function testSingleWithOptional(): void
159159
{
160160
$this->mock
161-
->expects(self::exactly(3))
161+
->expects($this->exactly(3))
162162
->method('singleWithOptional')
163163
->will(static::assert([
164164
['1'],
@@ -174,7 +174,7 @@ public function testSingleWithOptional(): void
174174
public function testSingleWithDefaultValue(): void
175175
{
176176
$this->mock
177-
->expects(self::exactly(3))
177+
->expects($this->exactly(3))
178178
->method('singleWithDefault')
179179
->will(static::assert([
180180
['1'],
@@ -190,7 +190,7 @@ public function testSingleWithDefaultValue(): void
190190
public function testDouble(): void
191191
{
192192
$this->mock
193-
->expects(self::exactly(3))
193+
->expects($this->exactly(3))
194194
->method('double')
195195
->will(static::assert([
196196
['1.1', '1.2'],
@@ -206,7 +206,7 @@ public function testDouble(): void
206206
public function testDoubleWithOptional(): void
207207
{
208208
$this->mock
209-
->expects(self::exactly(3))
209+
->expects($this->exactly(3))
210210
->method('doubleWithOptional')
211211
->will(static::assert([
212212
['1.1', '1.2'],
@@ -222,7 +222,7 @@ public function testDoubleWithOptional(): void
222222
public function testDoubleWithDefault(): void
223223
{
224224
$this->mock
225-
->expects(self::exactly(3))
225+
->expects($this->exactly(3))
226226
->method('doubleWithDefault')
227227
->will(static::assert([
228228
['1.1', '1.2'],
@@ -238,7 +238,7 @@ public function testDoubleWithDefault(): void
238238
public function testVariadic(): void
239239
{
240240
$this->mock
241-
->expects(self::exactly(3))
241+
->expects($this->exactly(3))
242242
->method('variadic')
243243
->will(static::assert([
244244
['1.1', '1.2', '1.3'],
@@ -254,7 +254,7 @@ public function testVariadic(): void
254254
public function testVariadicConstraint(): void
255255
{
256256
$this->mock
257-
->expects(self::exactly(4))
257+
->expects($this->exactly(4))
258258
->method('variadic')
259259
->will(static::assert([
260260
[new IsAnything(), '1.2', '1.3'],
@@ -275,11 +275,11 @@ public function testVariadicConstraint(): void
275275

276276
public function testVariadicFailMatch(): void
277277
{
278-
self::expectException(ExpectationFailedException::class);
279-
self::expectExceptionMessage("Parameter #2 for invocation #1 does not match expected value.\nFailed asserting that null matches expected '2.3'");
278+
$this->expectException(ExpectationFailedException::class);
279+
$this->expectExceptionMessage("Parameter #2 for invocation #1 does not match expected value.\nFailed asserting that null matches expected '2.3'");
280280

281281
$this->mock
282-
->expects(self::exactly(2))
282+
->expects($this->exactly(2))
283283
->method('variadic')
284284
->will(static::assert([
285285
['1.1', '1.2', '1.3'],

0 commit comments

Comments
 (0)