annotate vendor/phpunit/phpunit-mock-objects/tests/Invocation/StaticInvocationTest.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\MockObject\Invocation\StaticInvocation;
Chris@14 13
Chris@14 14 class StaticInvocationTest extends TestCase
Chris@14 15 {
Chris@14 16 public function testConstructorRequiresClassAndMethodAndParameters()
Chris@14 17 {
Chris@14 18 $this->assertInstanceOf(
Chris@14 19 StaticInvocation::class,
Chris@14 20 new StaticInvocation(
Chris@14 21 'FooClass',
Chris@14 22 'FooMethod',
Chris@14 23 ['an_argument'],
Chris@14 24 'ReturnType'
Chris@14 25 )
Chris@14 26 );
Chris@14 27 }
Chris@14 28
Chris@14 29 public function testAllowToGetClassNameSetInConstructor()
Chris@14 30 {
Chris@14 31 $invocation = new StaticInvocation(
Chris@14 32 'FooClass',
Chris@14 33 'FooMethod',
Chris@14 34 ['an_argument'],
Chris@14 35 'ReturnType'
Chris@14 36 );
Chris@14 37
Chris@14 38 $this->assertSame('FooClass', $invocation->getClassName());
Chris@14 39 }
Chris@14 40
Chris@14 41 public function testAllowToGetMethodNameSetInConstructor()
Chris@14 42 {
Chris@14 43 $invocation = new StaticInvocation(
Chris@14 44 'FooClass',
Chris@14 45 'FooMethod',
Chris@14 46 ['an_argument'],
Chris@14 47 'ReturnType'
Chris@14 48 );
Chris@14 49
Chris@14 50 $this->assertSame('FooMethod', $invocation->getMethodName());
Chris@14 51 }
Chris@14 52
Chris@14 53 public function testAllowToGetMethodParametersSetInConstructor()
Chris@14 54 {
Chris@14 55 $expectedParameters = [
Chris@14 56 'foo', 5, ['a', 'b'], new stdClass, null, false
Chris@14 57 ];
Chris@14 58
Chris@14 59 $invocation = new StaticInvocation(
Chris@14 60 'FooClass',
Chris@14 61 'FooMethod',
Chris@14 62 $expectedParameters,
Chris@14 63 'ReturnType'
Chris@14 64 );
Chris@14 65
Chris@14 66 $this->assertSame($expectedParameters, $invocation->getParameters());
Chris@14 67 }
Chris@14 68
Chris@14 69 public function testConstructorAllowToSetFlagCloneObjectsInParameters()
Chris@14 70 {
Chris@14 71 $parameters = [new stdClass];
Chris@14 72 $cloneObjects = true;
Chris@14 73
Chris@14 74 $invocation = new StaticInvocation(
Chris@14 75 'FooClass',
Chris@14 76 'FooMethod',
Chris@14 77 $parameters,
Chris@14 78 'ReturnType',
Chris@14 79 $cloneObjects
Chris@14 80 );
Chris@14 81
Chris@14 82 $this->assertEquals($parameters, $invocation->getParameters());
Chris@14 83 $this->assertNotSame($parameters, $invocation->getParameters());
Chris@14 84 }
Chris@14 85
Chris@14 86 public function testAllowToGetReturnTypeSetInConstructor()
Chris@14 87 {
Chris@14 88 $expectedReturnType = 'string';
Chris@14 89
Chris@14 90 $invocation = new StaticInvocation(
Chris@14 91 'FooClass',
Chris@14 92 'FooMethod',
Chris@14 93 ['an_argument'],
Chris@14 94 $expectedReturnType
Chris@14 95 );
Chris@14 96
Chris@14 97 $this->assertSame($expectedReturnType, $invocation->getReturnType());
Chris@14 98 }
Chris@14 99 }