assertEquals('This is a test', $call->getSummary()); $this->assertEquals("With more information\nin several lines", $call->getDescription()); $this->assertEquals( [ 'foo' => [ 'type' => 'string', 'description' => 'First variable', ], 'bar' => [ 'type' => 'int', 'description' => '', ] ], $call->getArgs() ); $this->assertEquals( [ 'type' => 'string', 'description' => 'The return' ], $call->getReturn() ); // remove one parameter $call->limitArgs(['foo']); $this->assertEquals( [ 'foo' => [ 'type' => 'string', 'description' => 'First variable', ], ], $call->getArgs() ); } public function testFunctionDocBlock() { $call = new ApiCall('date'); $call->setArgDescription('format', 'The format'); $this->assertEquals( [ 'format' => [ 'type' => 'string', 'description' => 'The format', ], 'timestamp' => [ 'type' => 'int', 'description' => '', ] ], $call->getArgs() ); } public function testExecution() { $call = new ApiCall([$this, 'dummyMethod1']); $this->assertEquals('dummy', $call(['bar', 1]), 'positional parameters'); $this->assertEquals('dummy', $call(['foo' => 'bar', 'bar' => 1]), 'named parameters'); $call = new ApiCall('date'); $this->assertEquals('2023-11-30', $call(['Y-m-d', 1701356591]), 'positional parameters'); $this->assertEquals('2023-11-30', $call(['format' => 'Y-m-d', 'timestamp' => 1701356591]), 'named parameters'); } }