Chris@14: Chris@14: * Chris@14: * For the full copyright and license information, please view the LICENSE Chris@14: * file that was distributed with this source code. Chris@14: */ Chris@14: Chris@14: use PHPUnit\Framework\TestCase; Chris@14: use PHPUnit\Framework\ExpectationFailedException; Chris@14: Chris@14: class ConsecutiveParametersTest extends TestCase Chris@14: { Chris@14: public function testIntegration() Chris@14: { Chris@14: $mock = $this->getMockBuilder(stdClass::class) Chris@14: ->setMethods(['foo']) Chris@14: ->getMock(); Chris@14: Chris@14: $mock->expects($this->any()) Chris@14: ->method('foo') Chris@14: ->withConsecutive( Chris@14: ['bar'], Chris@14: [21, 42] Chris@14: ); Chris@14: Chris@14: $this->assertNull($mock->foo('bar')); Chris@14: $this->assertNull($mock->foo(21, 42)); Chris@14: } Chris@14: Chris@14: public function testIntegrationWithLessAssertionsThanMethodCalls() Chris@14: { Chris@14: $mock = $this->getMockBuilder(stdClass::class) Chris@14: ->setMethods(['foo']) Chris@14: ->getMock(); Chris@14: Chris@14: $mock->expects($this->any()) Chris@14: ->method('foo') Chris@14: ->withConsecutive( Chris@14: ['bar'] Chris@14: ); Chris@14: Chris@14: $this->assertNull($mock->foo('bar')); Chris@14: $this->assertNull($mock->foo(21, 42)); Chris@14: } Chris@14: Chris@14: public function testIntegrationExpectingException() Chris@14: { Chris@14: $mock = $this->getMockBuilder(stdClass::class) Chris@14: ->setMethods(['foo']) Chris@14: ->getMock(); Chris@14: Chris@14: $mock->expects($this->any()) Chris@14: ->method('foo') Chris@14: ->withConsecutive( Chris@14: ['bar'], Chris@14: [21, 42] Chris@14: ); Chris@14: Chris@14: $mock->foo('bar'); Chris@14: Chris@14: $this->expectException(ExpectationFailedException::class); Chris@14: Chris@14: $mock->foo('invalid'); Chris@14: } Chris@14: }