Mercurial > hg > isophonics-drupal-site
comparison vendor/phpunit/phpunit-mock-objects/tests/Matcher/ConsecutiveParametersTest.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
1 <?php | |
2 /* | |
3 * This file is part of the phpunit-mock-objects package. | |
4 * | |
5 * (c) Sebastian Bergmann <sebastian@phpunit.de> | |
6 * | |
7 * For the full copyright and license information, please view the LICENSE | |
8 * file that was distributed with this source code. | |
9 */ | |
10 | |
11 use PHPUnit\Framework\TestCase; | |
12 use PHPUnit\Framework\ExpectationFailedException; | |
13 | |
14 class ConsecutiveParametersTest extends TestCase | |
15 { | |
16 public function testIntegration() | |
17 { | |
18 $mock = $this->getMockBuilder(stdClass::class) | |
19 ->setMethods(['foo']) | |
20 ->getMock(); | |
21 | |
22 $mock->expects($this->any()) | |
23 ->method('foo') | |
24 ->withConsecutive( | |
25 ['bar'], | |
26 [21, 42] | |
27 ); | |
28 | |
29 $this->assertNull($mock->foo('bar')); | |
30 $this->assertNull($mock->foo(21, 42)); | |
31 } | |
32 | |
33 public function testIntegrationWithLessAssertionsThanMethodCalls() | |
34 { | |
35 $mock = $this->getMockBuilder(stdClass::class) | |
36 ->setMethods(['foo']) | |
37 ->getMock(); | |
38 | |
39 $mock->expects($this->any()) | |
40 ->method('foo') | |
41 ->withConsecutive( | |
42 ['bar'] | |
43 ); | |
44 | |
45 $this->assertNull($mock->foo('bar')); | |
46 $this->assertNull($mock->foo(21, 42)); | |
47 } | |
48 | |
49 public function testIntegrationExpectingException() | |
50 { | |
51 $mock = $this->getMockBuilder(stdClass::class) | |
52 ->setMethods(['foo']) | |
53 ->getMock(); | |
54 | |
55 $mock->expects($this->any()) | |
56 ->method('foo') | |
57 ->withConsecutive( | |
58 ['bar'], | |
59 [21, 42] | |
60 ); | |
61 | |
62 $mock->foo('bar'); | |
63 | |
64 $this->expectException(ExpectationFailedException::class); | |
65 | |
66 $mock->foo('invalid'); | |
67 } | |
68 } |