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