diff --git a/Tests/AbstractApplicationTest.php b/Tests/AbstractApplicationTest.php index 79392610..41991efc 100644 --- a/Tests/AbstractApplicationTest.php +++ b/Tests/AbstractApplicationTest.php @@ -8,9 +8,14 @@ namespace Joomla\Application\Tests; use Joomla\Application\AbstractApplication; +use Joomla\Application\Event\ApplicationEvent; +use Joomla\Application\Web\WebClient; use Joomla\Event\DispatcherInterface; use Joomla\Registry\Registry; use Joomla\Test\TestHelper; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\TestDox; +use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; @@ -18,21 +23,37 @@ /** * Test class for Joomla\Application\AbstractApplication. */ +#[CoversClass(AbstractApplication::class)] +#[UsesClass(ApplicationEvent::class)] +#[UsesClass(WebClient::class)] class AbstractApplicationTest extends TestCase { /** - * @testdox Tests the constructor creates default object instances + * Returns a lightweight AbstractApplication instance for testing. * - * @covers Joomla\Application\AbstractApplication - * @uses Joomla\Application\AbstractApplication - * @uses Joomla\Application\Web\WebClient + * The anonymous class forwards all constructor arguments to the parent + * and provides an empty doExecute() implementation. + * + * @param mixed ...$args Constructor arguments for AbstractApplication + * + * @return AbstractApplication */ + private function getAbstractApplication(...$args): AbstractApplication + { + return new class (...$args) extends AbstractApplication { + protected function doExecute() + { + } + }; + } + + #[TestDox('Tests the constructor creates default object instances')] public function testConstructDefaultBehaviour() { $startTime = \time(); $startMicrotime = \microtime(true); - $object = $this->getMockForAbstractClass(AbstractApplication::class); + $object = $this->getAbstractApplication(); $this->assertInstanceOf( Registry::class, @@ -48,15 +69,11 @@ public function testConstructDefaultBehaviour() $this->assertGreaterThanOrEqual($startMicrotime, $object->get('execution.microtimestamp')); } - /** - * @testdox Tests the correct objects are stored when injected - * - * @covers Joomla\Application\AbstractApplication - */ + #[TestDox('Tests the correct objects are stored when injected')] public function testConstructDependencyInjection() { - $mockConfig = $this->createMock(Registry::class); - $object = $this->getMockForAbstractClass(AbstractApplication::class, [$mockConfig]); + $mockConfig = new Registry(); + $object = $this->getAbstractApplication($mockConfig); $this->assertSame( $mockConfig, @@ -65,52 +82,40 @@ public function testConstructDependencyInjection() ); } - /** - * @testdox Tests that \close() exits the application with the given code - * - * @covers Joomla\Application\AbstractApplication - */ + #[TestDox('Tests that \close() exits the application with the given code')] public function testClose() { - $object = $this->getMockBuilder(AbstractApplication::class) - ->onlyMethods(['close']) - ->disableOriginalConstructor() - ->getMockForAbstractClass(); + $object = $this->createMock(AbstractApplication::class); - $object->expects($this->any()) + $object->expects($this->once()) ->method('close') ->willReturnArgument(0); $this->assertSame(3, $object->close(3)); } - /** - * @testdox Tests that the application is executed successfully. - * - * @covers Joomla\Application\AbstractApplication - */ + #[TestDox('Tests that the application is executed successfully.')] public function testExecute() { - $object = $this->getMockForAbstractClass(AbstractApplication::class); + $object = $this->getMockBuilder(AbstractApplication::class) + ->onlyMethods(['doExecute']) + ->getMock(); $object->expects($this->once()) ->method('doExecute'); $object->execute(); } - /** - * @testdox Tests that the application is executed successfully when an event dispatcher is registered. - * - * @covers Joomla\Application\AbstractApplication - * @uses Joomla\Application\Event\ApplicationEvent - */ + #[TestDox('Tests that the application is executed successfully when an event dispatcher is registered.')] public function testExecuteWithEvents() { $dispatcher = $this->createMock(DispatcherInterface::class); $dispatcher->expects($this->exactly(2)) ->method('dispatch'); - $object = $this->getMockForAbstractClass(AbstractApplication::class); + $object = $this->getMockBuilder(AbstractApplication::class) + ->onlyMethods(['doExecute']) + ->getMock(); $object->expects($this->once()) ->method('doExecute'); @@ -119,62 +124,39 @@ public function testExecuteWithEvents() $object->execute(); } - /** - * @testdox Tests that data is read from the application configuration successfully. - * - * @covers Joomla\Application\AbstractApplication - */ + #[TestDox('Tests that data is read from the application configuration successfully.')] public function testGet() { - $mockConfig = $this->getMockBuilder(Registry::class) - ->setConstructorArgs([['foo' => 'bar']]) - ->enableProxyingToOriginalMethods() - ->getMock(); - - $object = $this->getMockForAbstractClass(AbstractApplication::class, [$mockConfig]); + $mockConfig = new Registry(['foo' => 'bar']); + $object = $this->getAbstractApplication($mockConfig); $this->assertSame('bar', $object->get('foo', 'car'), 'Checks a known configuration setting is returned.'); $this->assertSame('car', $object->get('goo', 'car'), 'Checks an unknown configuration setting returns the default.'); } - /** - * @testdox Tests that a default LoggerInterface object is returned. - * - * @covers Joomla\Application\AbstractApplication - */ + #[TestDox('Tests that a default LoggerInterface object is returned.')] public function testGetLogger() { - $object = $this->getMockForAbstractClass(AbstractApplication::class); + $object = $this->getAbstractApplication(); $this->assertInstanceOf(NullLogger::class, $object->getLogger()); } - /** - * @testdox Tests that data is set to the application configuration successfully. - * - * @covers Joomla\Application\AbstractApplication - */ + #[TestDox('Tests that data is set to the application configuration successfully.')] public function testSet() { - $mockConfig = $this->getMockBuilder(Registry::class) - ->enableProxyingToOriginalMethods() - ->getMock(); - - $object = $this->getMockForAbstractClass(AbstractApplication::class, [$mockConfig]); + $mockConfig = new Registry(); + $object = $this->getAbstractApplication($mockConfig); $this->assertNull($object->set('foo', 'car'), 'Checks set returns the previous value.'); $this->assertEquals('car', $object->get('foo'), 'Checks the new value has been set.'); } - /** - * @testdox Tests that the application configuration is overwritten successfully. - * - * @covers Joomla\Application\AbstractApplication - */ + #[TestDox('Tests that the application configuration is overwritten successfully.')] public function testSetConfiguration() { - $object = $this->getMockForAbstractClass(AbstractApplication::class); - $mockConfig = $this->createMock(Registry::class); + $object = $this->getAbstractApplication(); + $mockConfig = new Registry(); $this->assertSame($object, $object->setConfiguration($mockConfig), 'The setConfiguration method has a fluent interface'); @@ -185,15 +167,11 @@ public function testSetConfiguration() ); } - /** - * @testdox Tests that a LoggerInterface object is correctly set to the application. - * - * @covers Joomla\Application\AbstractApplication - */ + #[TestDox('Tests that a LoggerInterface object is correctly set to the application.')] public function testSetLogger() { - $object = $this->getMockForAbstractClass(AbstractApplication::class); - $mockLogger = $this->createMock(LoggerInterface::class); + $object = $this->getAbstractApplication(); + $mockLogger = $this->createStub(LoggerInterface::class); $object->setLogger($mockLogger); diff --git a/Tests/AbstractWebApplicationTest.php b/Tests/AbstractWebApplicationTest.php index 36908989..abca9e5c 100644 --- a/Tests/AbstractWebApplicationTest.php +++ b/Tests/AbstractWebApplicationTest.php @@ -7,18 +7,31 @@ namespace Joomla\Application\Tests; +use Joomla\Application\AbstractApplication; use Joomla\Application\AbstractWebApplication; +use Joomla\Application\Event\ApplicationEvent; use Joomla\Application\Web\WebClient; use Joomla\Event\DispatcherInterface; use Joomla\Input\Input; use Joomla\Registry\Registry; use Joomla\Test\TestHelper; use Laminas\Diactoros\Response\TextResponse; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; +use PHPUnit\Framework\Attributes\TestDox; +use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; /** * Test class for Joomla\Application\AbstractWebApplication. */ +#[CoversClass(AbstractWebApplication::class)] +#[UsesClass(AbstractApplication::class)] +#[UsesClass(ApplicationEvent::class)] +#[UsesClass(WebClient::class)] class AbstractWebApplicationTest extends TestCase { /** @@ -60,52 +73,73 @@ protected function tearDown(): void parent::tearDown(); } + /** + * Returns a lightweight AbstractWebApplication instance for testing. + * + * The anonymous class forwards all constructor arguments to the parent + * and provides an empty doExecute() implementation. + * + * @param mixed ...$args Constructor arguments for AbstractWebApplication + * + * @return AbstractWebApplication + */ + private function getAbstractWebApplication(...$args): AbstractWebApplication + { + return new class (...$args) extends AbstractWebApplication { + protected function doExecute() + { + } + }; + } + /** * Data for detectRequestUri method. * - * @return \Generator + * @return array */ - public static function getDetectRequestUriData(): \Generator + public static function getDetectRequestUriData(): array { - // HTTPS, PHP_SELF, REQUEST_URI, HTTP_HOST, SCRIPT_NAME, QUERY_STRING, (resulting uri) - yield 'HTTP connection with path in PHP_SELF and query string set in REQUEST_URI' => [ - null, - '/j/index.php', - '/j/index.php?foo=bar', - 'joom.la:3', - '/j/index.php', - '', - 'http://joom.la:3/j/index.php?foo=bar', - ]; + return [ + // HTTPS, PHP_SELF, REQUEST_URI, HTTP_HOST, SCRIPT_NAME, QUERY_STRING, (resulting uri) + 'HTTP connection with path in PHP_SELF and query string set in REQUEST_URI' => [ + null, + '/j/index.php', + '/j/index.php?foo=bar', + 'joom.la:3', + '/j/index.php', + '', + 'http://joom.la:3/j/index.php?foo=bar', + ], - yield 'HTTPS connection with path in PHP_SELF and query string set in REQUEST_URI' => [ - 'on', - '/j/index.php', - '/j/index.php?foo=bar', - 'joom.la:3', - '/j/index.php', - '', - 'https://joom.la:3/j/index.php?foo=bar', - ]; + 'HTTPS connection with path in PHP_SELF and query string set in REQUEST_URI' => [ + 'on', + '/j/index.php', + '/j/index.php?foo=bar', + 'joom.la:3', + '/j/index.php', + '', + 'https://joom.la:3/j/index.php?foo=bar', + ], - yield 'HTTP connection with path in SCRIPT_NAME and no query string' => [ - null, - '', - '', - 'joom.la:3', - '/j/index.php', - '', - 'http://joom.la:3/j/index.php', - ]; + 'HTTP connection with path in SCRIPT_NAME and no query string' => [ + null, + '', + '', + 'joom.la:3', + '/j/index.php', + '', + 'http://joom.la:3/j/index.php', + ], - yield 'HTTP connection with path in SCRIPT_NAME and query string set in QUERY_STRING' => [ - null, - '', - '', - 'joom.la:3', - '/j/index.php', - 'foo=bar', - 'http://joom.la:3/j/index.php?foo=bar', + 'HTTP connection with path in SCRIPT_NAME and query string set in QUERY_STRING' => [ + null, + '', + '', + 'joom.la:3', + '/j/index.php', + 'foo=bar', + 'http://joom.la:3/j/index.php?foo=bar', + ], ]; } @@ -137,44 +171,28 @@ public static function mockHeader($string, $replace = true, $code = null) self::$headers[] = [$string, $replace, $code]; } - /** - * @testdox Tests the constructor creates default object instances - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests the constructor creates default object instances')] public function testConstructDefaultBehaviour() { - $object = $this->getMockForAbstractClass(AbstractWebApplication::class); + $object = $this->getAbstractWebApplication(); // Validate default objects unique to the web application are created $this->assertInstanceOf(WebClient::class, $object->client); } - /** - * @testdox Tests the correct objects are stored when injected - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * - * @backupGlobals enabled - */ + #[BackupGlobals(true)] + #[TestDox('Tests the correct objects are stored when injected')] public function testConstructDependencyInjection() { $_SERVER['HTTP_HOST'] = self::TEST_HTTP_HOST; $_SERVER['REQUEST_URI'] = self::TEST_REQUEST_URI; $_SERVER['SCRIPT_NAME'] = self::TEST_REQUEST_URI; - $mockInput = new Input([]); + $mockInput = new Input([]); + $mockConfig = new Registry(); + $mockClient = new WebClient(); - $mockConfig = $this->getMockBuilder(Registry::class) - ->enableProxyingToOriginalMethods() - ->getMock(); - - $mockClient = $this->createMock(WebClient::class); - - $object = $this->getMockForAbstractClass(AbstractWebApplication::class, [$mockInput, $mockConfig, $mockClient]); + $object = $this->getAbstractWebApplication($mockInput, $mockConfig, $mockClient); $this->assertSame($mockInput, $object->getInput()); @@ -189,31 +207,21 @@ public function testConstructDependencyInjection() $this->assertEquals('http://' . self::TEST_HTTP_HOST, $object->get('uri.base.host')); } - /** - * @testdox Tests access to the input property is allowed - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests access to the input property is allowed')] public function testGetDeprecatedInputReadAccess() { - $object = $this->getMockForAbstractClass(AbstractWebApplication::class); + $object = $this->getAbstractWebApplication(); // Validate default objects unique to the web application are created $this->assertInstanceOf(Input::class, $object->getInput()); } - /** - * @testdox Tests that the application is executed successfully. - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests that the application is executed successfully.')] public function testExecute() { - $object = $this->getMockForAbstractClass(AbstractWebApplication::class); + $object = $this->getMockBuilder(AbstractWebApplication::class) + ->onlyMethods(['doExecute']) + ->getMock(); $object->expects($this->once()) ->method('doExecute'); @@ -234,21 +242,16 @@ public function testExecute() $this->assertEmpty($object->getBody()); } - /** - * @testdox Tests that the application is executed successfully when an event dispatcher is registered. - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Event\ApplicationEvent - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests that the application is executed successfully when an event dispatcher is registered.')] public function testExecuteWithEvents() { $dispatcher = $this->createMock(DispatcherInterface::class); $dispatcher->expects($this->exactly(4)) ->method('dispatch'); - $object = $this->getMockForAbstractClass(AbstractWebApplication::class); + $object = $this->getMockBuilder(AbstractWebApplication::class) + ->onlyMethods(['doExecute']) + ->getMock(); $object->expects($this->once()) ->method('doExecute'); @@ -271,13 +274,7 @@ public function testExecuteWithEvents() $this->assertEmpty($object->getBody()); } - /** - * @testdox Tests that the application with compression enabled is executed successfully. - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests that the application with compression enabled is executed successfully.')] public function testExecuteWithCompression() { // Verify compression is supported in this environment @@ -285,14 +282,16 @@ public function testExecuteWithCompression() $this->markTestSkipped('Output compression is unsupported in this environment.'); } - $mockConfig = $this->getMockBuilder(Registry::class) - ->setConstructorArgs([['gzip' => true]]) - ->enableProxyingToOriginalMethods() - ->getMock(); + $mockConfig = new Registry(['gzip' => true]); - $object = $this->getMockForAbstractClass(AbstractWebApplication::class, [null, $mockConfig]); + $object = $this->getMockBuilder(AbstractWebApplication::class) + ->setConstructorArgs([null, $mockConfig]) + ->onlyMethods(['doExecute', 'compress']) + ->getMock(); $object->expects($this->once()) ->method('doExecute'); + $object->expects($this->once()) + ->method('compress'); $object->execute(); @@ -311,40 +310,10 @@ public function testExecuteWithCompression() $this->assertEmpty($object->getBody()); } - /** - * @testdox Tests the \compress() method correctly compresses data with gzip encoding - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests the \compress() method correctly compresses data with gzip encoding')] public function testCompressWithGzipEncoding() { - $mockClient = $this->getMockBuilder(WebClient::class) - ->setConstructorArgs([null, 'gzip, deflate']) - ->enableProxyingToOriginalMethods() - ->getMock(); - - // Mock the client internals to show encoding has been detected. - TestHelper::setValue( - $mockClient, - 'detection', - ['acceptEncoding' => true] - ); - TestHelper::setValue( - $mockClient, - 'encodings', - ['gzip', 'deflate'] - ); - - $object = $this->getMockBuilder(AbstractWebApplication::class) - ->setConstructorArgs([null, null, $mockClient]) - ->onlyMethods(['checkHeadersSent']) - ->getMockForAbstractClass(); - - $object->expects($this->once()) - ->method('checkHeadersSent') - ->willReturn(false); + $mockClient = new WebClient(null, 'gzip, deflate'); // Mock a response. $response = new TextResponse( @@ -357,11 +326,14 @@ public function testCompressWithGzipEncoding() ); $response = $response->withoutHeader('content-type'); - TestHelper::setValue( - $object, - 'response', - $response - ); + $object = $this->getMockBuilder(AbstractWebApplication::class) + ->setConstructorArgs([null, null, $mockClient, $response]) + ->onlyMethods(['checkHeadersSent', 'doExecute']) + ->getMock(); + + $object->expects($this->once()) + ->method('checkHeadersSent') + ->willReturn(false); TestHelper::invoke($object, 'compress'); @@ -381,40 +353,10 @@ public function testCompressWithGzipEncoding() ); } - /** - * @testdox Tests the compress() method correctly compresses data with deflate encoding - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests the compress() method correctly compresses data with deflate encoding')] public function testCompressWithDeflateEncoding() { - $mockClient = $this->getMockBuilder(WebClient::class) - ->setConstructorArgs([null, 'deflate']) - ->enableProxyingToOriginalMethods() - ->getMock(); - - // Mock the client internals to show encoding has been detected. - TestHelper::setValue( - $mockClient, - 'detection', - ['acceptEncoding' => true] - ); - TestHelper::setValue( - $mockClient, - 'encodings', - ['deflate', 'gzip'] - ); - - $object = $this->getMockBuilder(AbstractWebApplication::class) - ->setConstructorArgs([null, null, $mockClient]) - ->onlyMethods(['checkHeadersSent']) - ->getMockForAbstractClass(); - - $object->expects($this->once()) - ->method('checkHeadersSent') - ->willReturn(false); + $mockClient = new WebClient(null, 'deflate'); // Mock a response. $response = new TextResponse( @@ -427,11 +369,14 @@ public function testCompressWithDeflateEncoding() ); $response = $response->withoutHeader('content-type'); - TestHelper::setValue( - $object, - 'response', - $response - ); + $object = $this->getMockBuilder(AbstractWebApplication::class) + ->setConstructorArgs([null, null, $mockClient, $response]) + ->onlyMethods(['checkHeadersSent', 'doExecute']) + ->getMock(); + + $object->expects($this->once()) + ->method('checkHeadersSent') + ->willReturn(false); TestHelper::invoke($object, 'compress'); @@ -451,30 +396,10 @@ public function testCompressWithDeflateEncoding() ); } - /** - * @testdox Tests the \compress() method does not compress data when no encoding methods are supported - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests the \compress() method does not compress data when no encoding methods are supported')] public function testCompressWithNoAcceptEncodings() { - $mockClient = $this->getMockBuilder(WebClient::class) - ->enableProxyingToOriginalMethods() - ->getMock(); - - // Mock the client internals to show encoding has been detected. - TestHelper::setValue( - $mockClient, - 'detection', - ['acceptEncoding' => true] - ); - - $object = $this->getMockBuilder(AbstractWebApplication::class) - ->setConstructorArgs([null, null, $mockClient]) - ->onlyMethods(['checkHeadersSent']) - ->getMockForAbstractClass(); + $mockClient = new WebClient(); // Mock a response. $response = new TextResponse( @@ -487,11 +412,7 @@ public function testCompressWithNoAcceptEncodings() ); $response = $response->withoutHeader('content-type'); - TestHelper::setValue( - $object, - 'response', - $response - ); + $object = $this->getAbstractWebApplication(null, null, $mockClient, $response); TestHelper::invoke($object, 'compress'); @@ -505,40 +426,10 @@ public function testCompressWithNoAcceptEncodings() $this->assertEmpty($object->getHeaders()); } - /** - * @testdox Tests the \compress() method does not compress data when the response headers have already been sent - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests the \compress() method does not compress data when the response headers have already been sent')] public function testCompressWithHeadersSent() { - $mockClient = $this->getMockBuilder(WebClient::class) - ->setConstructorArgs([null, 'deflate']) - ->enableProxyingToOriginalMethods() - ->getMock(); - - // Mock the client internals to show encoding has been detected. - TestHelper::setValue( - $mockClient, - 'detection', - ['acceptEncoding' => true] - ); - TestHelper::setValue( - $mockClient, - 'encodings', - ['deflate', 'gzip'] - ); - - $object = $this->getMockBuilder(AbstractWebApplication::class) - ->setConstructorArgs([null, null, $mockClient]) - ->onlyMethods(['checkHeadersSent']) - ->getMockForAbstractClass(); - - $object->expects($this->once()) - ->method('checkHeadersSent') - ->willReturn(true); + $mockClient = new WebClient(null, 'deflate'); // Mock a response. $response = new TextResponse( @@ -551,11 +442,14 @@ public function testCompressWithHeadersSent() ); $response = $response->withoutHeader('content-type'); - TestHelper::setValue( - $object, - 'response', - $response - ); + $object = $this->getMockBuilder(AbstractWebApplication::class) + ->setConstructorArgs([null, null, $mockClient, $response]) + ->onlyMethods(['checkHeadersSent', 'doExecute']) + ->getMock(); + + $object->expects($this->once()) + ->method('checkHeadersSent') + ->willReturn(true); TestHelper::invoke($object, 'compress'); @@ -569,33 +463,10 @@ public function testCompressWithHeadersSent() $this->assertEmpty($object->getHeaders()); } - /** - * @testdox Tests the \compress() method does not compress data when the application does not support the client's - * encoding methods - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests the \compress() method does not compress data when the application does not support the client\'s encoding methods')] public function testCompressWithUnsupportedEncodings() { - $mockClient = $this->getMockBuilder(WebClient::class) - ->enableProxyingToOriginalMethods() - ->getMock(); - - // Mock the client internals to show encoding has been detected. - TestHelper::setValue( - $mockClient, - 'detection', - ['acceptEncoding' => true] - ); - TestHelper::setValue( - $mockClient, - 'encodings', - ['foo', 'bar'] - ); - - $object = $this->getMockForAbstractClass(AbstractWebApplication::class, [null, null, $mockClient]); + $mockClient = new WebClient(); // Mock a response. $response = new TextResponse( @@ -608,11 +479,7 @@ public function testCompressWithUnsupportedEncodings() ); $response = $response->withoutHeader('content-type'); - TestHelper::setValue( - $object, - 'response', - $response - ); + $object = $this->getAbstractWebApplication(null, null, $mockClient, $response); TestHelper::invoke($object, 'compress'); @@ -626,16 +493,10 @@ public function testCompressWithUnsupportedEncodings() $this->assertEmpty($object->getHeaders()); } - /** - * @testdox Tests that the application sends the response successfully. - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests that the application sends the response successfully.')] public function testRespond() { - $object = $this->getMockForAbstractClass(AbstractWebApplication::class); + $object = $this->getAbstractWebApplication(); TestHelper::invoke($object, 'respond'); @@ -654,18 +515,12 @@ public function testRespond() $this->assertEmpty($object->getBody()); } - /** - * @testdox Tests that the application sends the response successfully with allowed caching. - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests that the application sends the response successfully with allowed caching.')] public function testRespondWithAllowedCaching() { $modifiedDate = new \DateTime('now', new \DateTimeZone('GMT')); - $object = $this->getMockForAbstractClass(AbstractWebApplication::class); + $object = $this->getAbstractWebApplication(); $object->allowCache(true); $object->modifiedDate = $modifiedDate; @@ -686,57 +541,29 @@ public function testRespondWithAllowedCaching() $this->assertEmpty($object->getBody()); } - /** - * @testdox Tests that the application redirects successfully with the legacy behavior. - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - * - * @backupGlobals enabled - */ + #[BackupGlobals(true)] + #[TestDox('Tests that the application redirects successfully with the legacy behavior.')] public function testRedirectLegacyBehavior() { $_SERVER['HTTP_HOST'] = self::TEST_HTTP_HOST; $_SERVER['REQUEST_URI'] = self::TEST_REQUEST_URI; $_SERVER['SCRIPT_NAME'] = self::TEST_REQUEST_URI; - $mockInput = new Input([]); + $mockInput = new Input([]); + $mockConfig = new Registry(); + $mockClient = new WebClient(); - $mockConfig = $this->getMockBuilder(Registry::class) - ->enableProxyingToOriginalMethods() + $object = $this->getMockBuilder(AbstractWebApplication::class) + ->setConstructorArgs([$mockInput, $mockConfig, $mockClient]) + ->onlyMethods(['checkHeadersSent', 'close', 'header', 'doExecute']) ->getMock(); - $mockClient = $this->createMock(WebClient::class); - - // Mock the client internals to show engine has been detected. - TestHelper::setValue( - $mockClient, - 'detection', - ['engine' => true] - ); - TestHelper::setValue( - $mockClient, - 'engine', - WebClient::GECKO - ); - - $object = $this->getMockForAbstractClass( - AbstractWebApplication::class, - [$mockInput, $mockConfig, $mockClient], - '', - true, - true, - true, - ['checkHeadersSent', 'close', 'header'] - ); - $object->expects($this->once()) ->method('close'); - $object->expects($this->any()) + $object->expects($this->exactly(2)) ->method('checkHeadersSent') ->willReturn(false); - $object->expects($this->any()) + $object->expects($this->exactly(7)) ->method('header') ->willReturnCallback([$this, 'mockHeader']); @@ -761,57 +588,29 @@ public function testRedirectLegacyBehavior() ); } - /** - * @testdox Tests that the application redirects successfully. - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - * - * @backupGlobals enabled - */ + #[BackupGlobals(true)] + #[TestDox('Tests that the application redirects successfully.')] public function testRedirect() { $_SERVER['HTTP_HOST'] = self::TEST_HTTP_HOST; $_SERVER['REQUEST_URI'] = self::TEST_REQUEST_URI; $_SERVER['SCRIPT_NAME'] = self::TEST_REQUEST_URI; - $mockInput = new Input([]); + $mockInput = new Input([]); + $mockConfig = new Registry(); + $mockClient = new WebClient(); - $mockConfig = $this->getMockBuilder(Registry::class) - ->enableProxyingToOriginalMethods() + $object = $this->getMockBuilder(AbstractWebApplication::class) + ->setConstructorArgs([$mockInput, $mockConfig, $mockClient]) + ->onlyMethods(['checkHeadersSent', 'close', 'header', 'doExecute']) ->getMock(); - $mockClient = $this->getMockBuilder(WebClient::class)->getMock(); - - // Mock the client internals to show engine has been detected. - TestHelper::setValue( - $mockClient, - 'detection', - ['engine' => true] - ); - TestHelper::setValue( - $mockClient, - 'engine', - WebClient::GECKO - ); - - $object = $this->getMockForAbstractClass( - AbstractWebApplication::class, - [$mockInput, $mockConfig, $mockClient], - '', - true, - true, - true, - ['checkHeadersSent', 'close', 'header'] - ); - $object->expects($this->once()) ->method('close'); - $object->expects($this->any()) + $object->expects($this->exactly(2)) ->method('checkHeadersSent') ->willReturn(false); - $object->expects($this->any()) + $object->expects($this->exactly(7)) ->method('header') ->willReturnCallback([$this, 'mockHeader']); @@ -835,57 +634,29 @@ public function testRedirect() ); } - /** - * @testdox Tests that the application redirects successfully when there is already a status code set. - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - * - * @backupGlobals enabled - */ + #[BackupGlobals(true)] + #[TestDox('Tests that the application redirects successfully when there is already a status code set.')] public function testRedirectWithExistingStatusCode() { $_SERVER['HTTP_HOST'] = self::TEST_HTTP_HOST; $_SERVER['REQUEST_URI'] = self::TEST_REQUEST_URI; $_SERVER['SCRIPT_NAME'] = self::TEST_REQUEST_URI; - $mockInput = new Input([]); + $mockInput = new Input([]); + $mockConfig = new Registry(); + $mockClient = new WebClient(); - $mockConfig = $this->getMockBuilder(Registry::class) - ->enableProxyingToOriginalMethods() + $object = $this->getMockBuilder(AbstractWebApplication::class) + ->setConstructorArgs([$mockInput, $mockConfig, $mockClient]) + ->onlyMethods(['checkHeadersSent', 'close', 'header', 'doExecute']) ->getMock(); - $mockClient = $this->getMockBuilder(WebClient::class)->getMock(); - - // Mock the client internals to show engine has been detected. - TestHelper::setValue( - $mockClient, - 'detection', - ['engine' => true] - ); - TestHelper::setValue( - $mockClient, - 'engine', - WebClient::GECKO - ); - - $object = $this->getMockForAbstractClass( - AbstractWebApplication::class, - [$mockInput, $mockConfig, $mockClient], - '', - true, - true, - true, - ['checkHeadersSent', 'close', 'header'] - ); - $object->expects($this->once()) ->method('close'); - $object->expects($this->any()) + $object->expects($this->exactly(2)) ->method('checkHeadersSent') ->willReturn(false); - $object->expects($this->any()) + $object->expects($this->exactly(7)) ->method('header') ->willReturnCallback([$this, 'mockHeader']); @@ -911,57 +682,29 @@ public function testRedirectWithExistingStatusCode() ); } - /** - * @testdox Tests that the application redirects and sends additional headers successfully. - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - * - * @backupGlobals enabled - */ + #[BackupGlobals(true)] + #[TestDox('Tests that the application redirects and sends additional headers successfully.')] public function testRedirectWithAdditionalHeaders() { $_SERVER['HTTP_HOST'] = self::TEST_HTTP_HOST; $_SERVER['REQUEST_URI'] = self::TEST_REQUEST_URI; $_SERVER['SCRIPT_NAME'] = self::TEST_REQUEST_URI; - $mockInput = new Input([]); + $mockInput = new Input([]); + $mockConfig = new Registry(); + $mockClient = new WebClient(); - $mockConfig = $this->getMockBuilder(Registry::class) - ->enableProxyingToOriginalMethods() + $object = $this->getMockBuilder(AbstractWebApplication::class) + ->setConstructorArgs([$mockInput, $mockConfig, $mockClient]) + ->onlyMethods(['checkHeadersSent', 'close', 'header', 'doExecute']) ->getMock(); - $mockClient = $this->getMockBuilder(WebClient::class)->getMock(); - - // Mock the client internals to show engine has been detected. - TestHelper::setValue( - $mockClient, - 'detection', - ['engine' => true] - ); - TestHelper::setValue( - $mockClient, - 'engine', - WebClient::GECKO - ); - - $object = $this->getMockForAbstractClass( - AbstractWebApplication::class, - [$mockInput, $mockConfig, $mockClient], - '', - true, - true, - true, - ['checkHeadersSent', 'close', 'header'] - ); - $object->expects($this->once()) ->method('close'); - $object->expects($this->any()) + $object->expects($this->exactly(2)) ->method('checkHeadersSent') ->willReturn(false); - $object->expects($this->any()) + $object->expects($this->exactly(7)) ->method('header') ->willReturnCallback([$this, 'mockHeader']); @@ -986,43 +729,28 @@ public function testRedirectWithAdditionalHeaders() ); } - /** - * @testdox Tests that the application redirects successfully when the headers have already been sent. - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - * - * @runInSeparateProcess - * @preserveGlobalState disabled - * @backupGlobals enabled - */ + #[BackupGlobals(true)] + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] + #[TestDox('Tests that the application redirects successfully when the headers have already been sent.')] public function testRedirectWithHeadersSent() { $_SERVER['HTTP_HOST'] = self::TEST_HTTP_HOST; $_SERVER['REQUEST_URI'] = self::TEST_REQUEST_URI; $_SERVER['SCRIPT_NAME'] = self::TEST_REQUEST_URI; - $mockInput = new Input([]); + $mockInput = new Input([]); + $mockConfig = new Registry(); - $mockConfig = $this->getMockBuilder(Registry::class) - ->enableProxyingToOriginalMethods() + $object = $this->getMockBuilder(AbstractWebApplication::class) + ->setConstructorArgs([$mockInput, $mockConfig]) + ->onlyMethods(['checkHeadersSent', 'close', 'doExecute']) ->getMock(); - $object = $this->getMockForAbstractClass( - AbstractWebApplication::class, - [$mockInput, $mockConfig], - '', - true, - true, - true, - ['checkHeadersSent', 'close'] - ); - $object->expects($this->once()) ->method('close') ->willReturn(true); - $object->expects($this->any()) + $object->expects($this->exactly(2)) ->method('checkHeadersSent') ->willReturn(true); @@ -1041,57 +769,26 @@ public function testRedirectWithHeadersSent() ); } - /** - * @testdox Tests that the application redirects successfully with a JavaScript redirect. - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - * - * @backupGlobals enabled - */ + #[BackupGlobals(true)] + #[TestDox('Tests that the application redirects successfully with a JavaScript redirect.')] public function testRedirectWithJavascriptRedirect() { $_SERVER['HTTP_HOST'] = self::TEST_HTTP_HOST; $_SERVER['REQUEST_URI'] = self::TEST_REQUEST_URI; $_SERVER['SCRIPT_NAME'] = self::TEST_REQUEST_URI; - $mockInput = new Input([]); - - $mockConfig = $this->getMockBuilder(Registry::class) - ->enableProxyingToOriginalMethods() - ->getMock(); + $mockInput = new Input([]); + $mockConfig = new Registry(); + $mockClient = new WebClient('MSIE'); - $mockClient = $this->getMockBuilder(WebClient::class) - ->setConstructorArgs(['MSIE']) - ->enableProxyingToOriginalMethods() + $object = $this->getMockBuilder(AbstractWebApplication::class) + ->setConstructorArgs([$mockInput, $mockConfig, $mockClient]) + ->onlyMethods(['checkHeadersSent', 'close', 'doExecute']) ->getMock(); - // Mock the client internals to show engine has been detected. - TestHelper::setValue( - $mockClient, - 'detection', - ['engine' => true] - ); - TestHelper::setValue( - $mockClient, - 'engine', - WebClient::TRIDENT - ); - - $object = $this->getMockForAbstractClass( - AbstractWebApplication::class, - [$mockInput, $mockConfig, $mockClient], - '', - true, - true, - true, - ['checkHeadersSent', 'close', 'header'] - ); - $object->expects($this->once()) ->method('close'); - $object->expects($this->any()) + $object->expects($this->exactly(2)) ->method('checkHeadersSent') ->willReturn(false); @@ -1109,57 +806,29 @@ public function testRedirectWithJavascriptRedirect() ); } - /** - * @testdox Tests that the application redirects successfully with the moved parameter set to true. - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - * - * @backupGlobals enabled - */ + #[BackupGlobals(true)] + #[TestDox('Tests that the application redirects successfully with the moved parameter set to true.')] public function testRedirectWithMoved() { $_SERVER['HTTP_HOST'] = self::TEST_HTTP_HOST; $_SERVER['REQUEST_URI'] = self::TEST_REQUEST_URI; $_SERVER['SCRIPT_NAME'] = self::TEST_REQUEST_URI; - $mockInput = new Input([]); + $mockInput = new Input([]); + $mockConfig = new Registry(); + $mockClient = new WebClient(); - $mockConfig = $this->getMockBuilder(Registry::class) - ->enableProxyingToOriginalMethods() + $object = $this->getMockBuilder(AbstractWebApplication::class) + ->setConstructorArgs([$mockInput, $mockConfig, $mockClient]) + ->onlyMethods(['checkHeadersSent', 'close', 'header', 'doExecute']) ->getMock(); - $mockClient = $this->getMockBuilder(WebClient::class)->getMock(); - - // Mock the client internals to show engine has been detected. - TestHelper::setValue( - $mockClient, - 'detection', - ['engine' => true] - ); - TestHelper::setValue( - $mockClient, - 'engine', - WebClient::GECKO - ); - - $object = $this->getMockForAbstractClass( - AbstractWebApplication::class, - [$mockInput, $mockConfig, $mockClient], - '', - true, - true, - true, - ['checkHeadersSent', 'close', 'header'] - ); - $object->expects($this->once()) ->method('close'); - $object->expects($this->any()) + $object->expects($this->exactly(2)) ->method('checkHeadersSent') ->willReturn(false); - $object->expects($this->any()) + $object->expects($this->exactly(7)) ->method('header') ->willReturnCallback([$this, 'mockHeader']); @@ -1185,60 +854,33 @@ public function testRedirectWithMoved() } /** - * @testdox Tests that the application redirects successfully with the moved parameter set to true. - * * @param string $url The URL to redirect to * @param string $expected The expected redirect URL - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - * - * @dataProvider getRedirectData - * @backupGlobals enabled */ + #[BackupGlobals(true)] + #[DataProvider('getRedirectData')] + #[TestDox('Tests that the application redirects successfully with the moved parameter set to true.')] public function testRedirectWithUrl(string $url, string $expected) { $_SERVER['HTTP_HOST'] = self::TEST_HTTP_HOST; $_SERVER['REQUEST_URI'] = self::TEST_REQUEST_URI; $_SERVER['SCRIPT_NAME'] = self::TEST_REQUEST_URI; - $mockInput = new Input([]); + $mockInput = new Input([]); + $mockConfig = new Registry(); + $mockClient = new WebClient(); - $mockConfig = $this->getMockBuilder(Registry::class) - ->enableProxyingToOriginalMethods() + $object = $this->getMockBuilder(AbstractWebApplication::class) + ->setConstructorArgs([$mockInput, $mockConfig, $mockClient]) + ->onlyMethods(['checkHeadersSent', 'close', 'header', 'doExecute']) ->getMock(); - $mockClient = $this->getMockBuilder(WebClient::class)->getMock(); - - // Mock the client internals to show engine has been detected. - TestHelper::setValue( - $mockClient, - 'detection', - ['engine' => true] - ); - TestHelper::setValue( - $mockClient, - 'engine', - WebClient::GECKO - ); - - $object = $this->getMockForAbstractClass( - AbstractWebApplication::class, - [$mockInput, $mockConfig, $mockClient], - '', - true, - true, - true, - ['checkHeadersSent', 'close', 'header'] - ); - $object->expects($this->once()) ->method('close'); - $object->expects($this->any()) + $object->expects($this->exactly(2)) ->method('checkHeadersSent') ->willReturn(false); - $object->expects($this->any()) + $object->expects($this->exactly(7)) ->method('header') ->willReturnCallback([$this, 'mockHeader']); @@ -1250,31 +892,19 @@ public function testRedirectWithUrl(string $url, string $expected) ); } - /** - * @testdox Tests the \allowCache() method returns the allowed cache state - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests the \allowCache() method returns the allowed cache state')] public function testAllowCache() { - $object = $this->getMockForAbstractClass(AbstractWebApplication::class); + $object = $this->getAbstractWebApplication(); $this->assertFalse($object->allowCache()); $this->assertTrue($object->allowCache(true)); } - /** - * @testdox Tests the \setHeader() method correctly sets and replaces a specified header - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests the \setHeader() method correctly sets and replaces a specified header')] public function testSetHeader() { - $object = $this->getMockForAbstractClass(AbstractWebApplication::class); + $object = $this->getAbstractWebApplication(); $object->setHeader('foo', 'bar'); @@ -1296,16 +926,10 @@ public function testSetHeader() ); } - /** - * @testdox Tests the \clearHeaders() method resets the internal headers array - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests the \clearHeaders() method resets the internal headers array')] public function testClearHeaders() { - $object = $this->getMockForAbstractClass(AbstractWebApplication::class); + $object = $this->getAbstractWebApplication(); $object->setHeader('foo', 'bar'); $oldHeaders = $object->getHeaders(); @@ -1313,29 +937,17 @@ public function testClearHeaders() $this->assertNotSame($oldHeaders, $object->getHeaders()); } - /** - * @testdox Tests the \sendHeaders() method correctly sends the response headers - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests the \sendHeaders() method correctly sends the response headers')] public function testSendHeaders() { - $object = $this->getMockForAbstractClass( - AbstractWebApplication::class, - [], - '', - true, - true, - true, - ['checkHeadersSent', 'header'] - ); + $object = $this->getMockBuilder(AbstractWebApplication::class) + ->onlyMethods(['checkHeadersSent', 'header', 'doExecute']) + ->getMock(); - $object->expects($this->any()) + $object->expects($this->once()) ->method('checkHeadersSent') ->willReturn(false); - $object->expects($this->any()) + $object->expects($this->exactly(2)) ->method('header') ->willReturnCallback([$this, 'mockHeader']); @@ -1352,70 +964,44 @@ public function testSendHeaders() ); } - /** - * @testdox Tests the \setBody() method correctly sets the response body - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests the \setBody() method correctly sets the response body')] public function testSetBody() { - $object = $this->getMockForAbstractClass(AbstractWebApplication::class); + $object = $this->getAbstractWebApplication(); $this->assertSame($object, $object->setBody('Testing')); $this->assertSame('Testing', $object->getBody()); } - /** - * @testdox Tests the \prependBody() method correctly prepends content to the response body - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests the \prependBody() method correctly prepends content to the response body')] public function testPrependBody() { - $object = $this->getMockForAbstractClass(AbstractWebApplication::class); + $object = $this->getAbstractWebApplication(); $object->setBody('Testing'); $this->assertSame($object, $object->prependBody('Pre-')); $this->assertSame('Pre-Testing', $object->getBody()); } - /** - * @testdox Tests the \appendBody() method correctly appends content to the response body - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests the \appendBody() method correctly appends content to the response body')] public function testAppendBody() { - $object = $this->getMockForAbstractClass(AbstractWebApplication::class); + $object = $this->getAbstractWebApplication(); $object->setBody('Testing'); $this->assertSame($object, $object->appendBody(' Later')); $this->assertSame('Testing Later', $object->getBody()); } - /** - * @testdox Tests the \getBody() method correctly retrieves the response body - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests the \getBody() method correctly retrieves the response body')] public function testGetBody() { - $object = $this->getMockForAbstractClass(AbstractWebApplication::class); + $object = $this->getAbstractWebApplication(); $this->assertSame('', $object->getBody(), 'Returns an empty string by default'); } /** - * @testdox Tests that the application correctly detects the request URI based on the injected data - * * @param string|null $https Value for $_SERVER['HTTPS'] or null to not set it * @param string $phpSelf Value for $_SERVER['PHP_SELF'] * @param string $requestUri Value for $_SERVER['REQUEST_URI'] @@ -1423,14 +1009,10 @@ public function testGetBody() * @param string $scriptName Value for $_SERVER['SCRIPT_NAME'] * @param string $queryString Value for $_SERVER['QUERY_STRING'] * @param string $expects Expected full URI string - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - * - * @dataProvider getDetectRequestUriData - * @backupGlobals enabled */ + #[BackupGlobals(true)] + #[DataProvider('getDetectRequestUriData')] + #[TestDox('Tests that the application correctly detects the request URI based on the injected data')] public function testDetectRequestUri( ?string $https, string $phpSelf, @@ -1452,7 +1034,7 @@ public function testDetectRequestUri( $_SERVER['HTTPS'] = $https; } - $object = $this->getMockForAbstractClass(AbstractWebApplication::class, [$mockInput]); + $object = $this->getAbstractWebApplication($mockInput); $this->assertSame( $expects, @@ -1460,21 +1042,11 @@ public function testDetectRequestUri( ); } - /** - * @testdox Tests the system URIs are correctly loaded when a URI is set in the application configuration - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests the system URIs are correctly loaded when a URI is set in the application configuration')] public function testLoadSystemUrisWithSiteUriSet() { - $mockConfig = $this->getMockBuilder(Registry::class) - ->setConstructorArgs([['site_uri' => 'http://test.joomla.org/path/']]) - ->enableProxyingToOriginalMethods() - ->getMock(); - - $object = $this->getMockForAbstractClass(AbstractWebApplication::class, [null, $mockConfig]); + $mockConfig = new Registry(['site_uri' => 'http://test.joomla.org/path/']); + $object = $this->getAbstractWebApplication(null, $mockConfig); TestHelper::invoke($object, 'loadSystemUris'); @@ -1504,23 +1076,15 @@ public function testLoadSystemUrisWithSiteUriSet() ); } - /** - * @testdox Tests the system URIs are correctly loaded when a URI is passed into the method - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - * - * @backupGlobals enabled - */ + #[BackupGlobals(true)] + #[TestDox('Tests the system URIs are correctly loaded when a URI is passed into the method')] public function testLoadSystemUrisWithoutSiteUriSet() { $_SERVER['HTTP_HOST'] = self::TEST_HTTP_HOST; $_SERVER['SCRIPT_NAME'] = self::TEST_REQUEST_URI; $mockInput = new Input([]); - - $object = $this->getMockForAbstractClass(AbstractWebApplication::class, [$mockInput]); + $object = $this->getAbstractWebApplication($mockInput); TestHelper::invoke($object, 'loadSystemUris', 'http://joom.la/application'); @@ -1550,29 +1114,16 @@ public function testLoadSystemUrisWithoutSiteUriSet() ); } - /** - * @testdox Tests the system URIs are correctly loaded when a media URI is set in the application - * configuration - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - * - * @backupGlobals enabled - */ + #[BackupGlobals(true)] + #[TestDox('Tests the system URIs are correctly loaded when a media URI is set in the application configuration')] public function testLoadSystemUrisWithoutSiteUriWithMediaUriSet() { $_SERVER['HTTP_HOST'] = self::TEST_HTTP_HOST; $_SERVER['SCRIPT_NAME'] = self::TEST_REQUEST_URI; - $mockInput = new Input([]); - - $mockConfig = $this->getMockBuilder(Registry::class) - ->setConstructorArgs([['media_uri' => 'http://cdn.joomla.org/media/']]) - ->enableProxyingToOriginalMethods() - ->getMock(); - - $object = $this->getMockForAbstractClass(AbstractWebApplication::class, [$mockInput, $mockConfig]); + $mockInput = new Input([]); + $mockConfig = new Registry(['media_uri' => 'http://cdn.joomla.org/media/']); + $object = $this->getAbstractWebApplication($mockInput, $mockConfig); TestHelper::invoke($object, 'loadSystemUris', 'http://joom.la/application'); @@ -1602,29 +1153,16 @@ public function testLoadSystemUrisWithoutSiteUriWithMediaUriSet() ); } - /** - * @testdox Tests the system URIs are correctly loaded when a relative media URI is set in the application - * configuration - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - * - * @backupGlobals enabled - */ + #[BackupGlobals(true)] + #[TestDox('Tests the system URIs are correctly loaded when a relative media URI is set in the application configuration')] public function testLoadSystemUrisWithoutSiteUriWithRelativeMediaUriSet() { $_SERVER['HTTP_HOST'] = self::TEST_HTTP_HOST; $_SERVER['SCRIPT_NAME'] = self::TEST_REQUEST_URI; - $mockInput = new Input([]); - - $mockConfig = $this->getMockBuilder(Registry::class) - ->setConstructorArgs([['media_uri' => '/media/']]) - ->enableProxyingToOriginalMethods() - ->getMock(); - - $object = $this->getMockForAbstractClass(AbstractWebApplication::class, [$mockInput, $mockConfig]); + $mockInput = new Input([]); + $mockConfig = new Registry(['media_uri' => '/media/']); + $object = $this->getAbstractWebApplication($mockInput, $mockConfig); TestHelper::invoke($object, 'loadSystemUris', 'http://joom.la/application'); @@ -1654,18 +1192,11 @@ public function testLoadSystemUrisWithoutSiteUriWithRelativeMediaUriSet() ); } - /** - * @testdox Tests the application correctly detects if a SSL connection is active - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - * - * @backupGlobals enabled - */ + #[BackupGlobals(true)] + #[TestDox('Tests the application correctly detects if a SSL connection is active')] public function testisSslConnection() { - $object = $this->getMockForAbstractClass(AbstractWebApplication::class); + $object = $this->getAbstractWebApplication(); $this->assertFalse($object->isSslConnection()); @@ -1674,30 +1205,18 @@ public function testisSslConnection() $this->assertTrue($object->isSslConnection()); } - /** - * @testdox Tests the application correctly approves a valid HTTP Status Code - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests the application correctly approves a valid HTTP Status Code')] public function testGetHttpStatusValue() { - $object = $this->getMockForAbstractClass(AbstractWebApplication::class); + $object = $this->getAbstractWebApplication(); $this->assertTrue($object->isValidHttpStatus(500)); } - /** - * @testdox Tests the application correctly rejects a valid HTTP Status Code - * - * @covers \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests the application correctly rejects a valid HTTP Status Code')] public function testInvalidHttpStatusValue() { - $object = $this->getMockForAbstractClass(AbstractWebApplication::class); + $object = $this->getAbstractWebApplication(); $this->assertFalse($object->isValidHttpStatus(460)); } diff --git a/Tests/Controller/ContainerControllerResolverTest.php b/Tests/Controller/ContainerControllerResolverTest.php index a0350c7d..7d8c908c 100644 --- a/Tests/Controller/ContainerControllerResolverTest.php +++ b/Tests/Controller/ContainerControllerResolverTest.php @@ -8,15 +8,21 @@ namespace Joomla\Application\Tests\Controller; use Joomla\Application\Controller\ContainerControllerResolver; +use Joomla\Application\Controller\ControllerResolver; use Joomla\Application\Tests\Stubs\Controller; use Joomla\Application\Tests\Stubs\HasArgumentsController; use Joomla\DI\Container; use Joomla\Router\ResolvedRoute; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\TestDox; +use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; /** * Test class for Joomla\Application\Controller\ContainerControllerResolver. */ +#[CoversClass(ContainerControllerResolver::class)] +#[UsesClass(ControllerResolver::class)] class ContainerControllerResolverTest extends TestCase { /** @@ -43,26 +49,16 @@ function () { $this->resolver = new ContainerControllerResolver($container); } - /** - * @testdox Tests the resolver resolves a ControllerInterface - * - * @covers Joomla\Application\Controller\ContainerControllerResolver - * @uses Joomla\Application\Controller\ControllerResolver - */ + #[TestDox('Tests the resolver resolves a ControllerInterface')] public function testResolvingAControllerInterface() { $callable = $this->resolver->resolve(new ResolvedRoute(Controller::class, [], '/')); - $this->assertTrue(\is_callable($callable)); + $this->assertIsCallable($callable); $this->assertInstanceOf(Controller::class, $callable[0]); } - /** - * @testdox Tests the resolver resolves a ControllerInterface but fails instantiating a class with required arguments - * - * @covers Joomla\Application\Controller\ContainerControllerResolver - * @uses Joomla\Application\Controller\ControllerResolver - */ + #[TestDox('Tests the resolver resolves a ControllerInterface but fails instantiating a class with required arguments')] public function testResolvingControllerInterfaceFailsOnAClassWithRequiredArguments() { $this->expectException(\InvalidArgumentException::class); diff --git a/Tests/Controller/ControllerResolverTest.php b/Tests/Controller/ControllerResolverTest.php index a9741eed..98ebec73 100644 --- a/Tests/Controller/ControllerResolverTest.php +++ b/Tests/Controller/ControllerResolverTest.php @@ -12,31 +12,26 @@ use Joomla\Application\Tests\Stubs\HasArgumentsController; use Joomla\Registry\Registry; use Joomla\Router\ResolvedRoute; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\TestCase; /** * Test class for Joomla\Application\Controller\ControllerResolver. */ +#[CoversClass(ControllerResolver::class)] class ControllerResolverTest extends TestCase { - /** - * @testdox Tests the resolver resolves a callable array - * - * @covers Joomla\Application\Controller\ControllerResolver - */ + #[TestDox('Tests the resolver resolves a callable array')] public function testResolvingACallableArray() { $callable = (new ControllerResolver())->resolve(new ResolvedRoute([Registry::class, 'get'], [], '/')); - $this->assertTrue(\is_callable($callable)); + $this->assertIsCallable($callable); $this->assertInstanceOf(Registry::class, $callable[0]); } - /** - * @testdox Tests the resolver fails to resolve an array that is not callable - * - * @covers Joomla\Application\Controller\ControllerResolver - */ + #[TestDox('Tests the resolver fails to resolve an array that is not callable')] public function testResolvingAnArrayFailsWhenNonCollable() { $this->expectException(\InvalidArgumentException::class); @@ -45,11 +40,7 @@ public function testResolvingAnArrayFailsWhenNonCollable() (new ControllerResolver())->resolve(new ResolvedRoute([Registry::class, 'noWayThisWillEverExist'], [], '/')); } - /** - * @testdox Tests the resolver resolves a callable array but fails instantiating a class with required arguments - * - * @covers Joomla\Application\Controller\ControllerResolver - */ + #[TestDox('Tests the resolver resolves a callable array but fails instantiating a class with required arguments')] public function testResolvingACallableArrayFailsOnAClassWithRequiredArguments() { $this->expectException(\InvalidArgumentException::class); @@ -58,11 +49,7 @@ public function testResolvingACallableArrayFailsOnAClassWithRequiredArguments() (new ControllerResolver())->resolve(new ResolvedRoute([HasArgumentsController::class, 'execute'], [], '/')); } - /** - * @testdox Tests the resolver resolves a callable object - * - * @covers Joomla\Application\Controller\ControllerResolver - */ + #[TestDox('Tests the resolver resolves a callable object')] public function testResolvingACallableObject() { $controller = function () { @@ -72,34 +59,22 @@ public function testResolvingACallableObject() $this->assertSame($controller, (new ControllerResolver())->resolve(new ResolvedRoute($controller, [], '/'))); } - /** - * @testdox Tests the resolver resolves a callable function - * - * @covers Joomla\Application\Controller\ControllerResolver - */ + #[TestDox('Tests the resolver resolves a callable function')] public function testResolvingACallableFunction() { $this->assertSame('str_replace', (new ControllerResolver())->resolve(new ResolvedRoute('str_replace', [], '/'))); } - /** - * @testdox Tests the resolver resolves a ControllerInterface - * - * @covers Joomla\Application\Controller\ControllerResolver - */ + #[TestDox('Tests the resolver resolves a ControllerInterface')] public function testResolvingAControllerInterface() { $callable = (new ControllerResolver())->resolve(new ResolvedRoute(Controller::class, [], '/')); - $this->assertTrue(\is_callable($callable)); + $this->assertIsCallable($callable); $this->assertInstanceOf(Controller::class, $callable[0]); } - /** - * @testdox Tests the resolver resolves a ControllerInterface but fails instantiating a class with required arguments - * - * @covers Joomla\Application\Controller\ControllerResolver - */ + #[TestDox('Tests the resolver resolves a ControllerInterface but fails instantiating a class with required arguments')] public function testResolvingControllerInterfaceFailsOnAClassWithRequiredArguments() { $this->expectException(\InvalidArgumentException::class); diff --git a/Tests/SessionAwareWebApplicationTraitTest.php b/Tests/SessionAwareWebApplicationTraitTest.php index bbf1b3d2..569b5b03 100644 --- a/Tests/SessionAwareWebApplicationTraitTest.php +++ b/Tests/SessionAwareWebApplicationTraitTest.php @@ -7,60 +7,74 @@ namespace Joomla\Application\Tests; +use Joomla\Application\AbstractApplication; +use Joomla\Application\AbstractWebApplication; use Joomla\Application\SessionAwareWebApplicationTrait; +use Joomla\Application\Web\WebClient; +use Joomla\Application\WebApplication; use Joomla\Input\Input; use Joomla\Session\SessionInterface; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\CoversTrait; +use PHPUnit\Framework\Attributes\TestDox; +use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; /** * Test class for Joomla\Application\SessionAwareWebApplicationTrait. */ +#[CoversTrait(SessionAwareWebApplicationTrait::class)] +#[UsesClass(AbstractApplication::class)] +#[UsesClass(AbstractWebApplication::class)] +#[UsesClass(WebApplication::class)] +#[UsesClass(WebClient::class)] class SessionAwareWebApplicationTraitTest extends TestCase { /** - * @testdox Tests a session object is correctly injected into the application and retrieved + * Returns a lightweight object using SessionAwareWebApplicationTrait. * - * @covers Joomla\Application\SessionAwareWebApplicationTrait + * The anonymous class provides a simple getInput() implementation, + * making it suitable for tests that require a minimal trait consumer. + * + * @return object An object using SessionAwareWebApplicationTrait */ + private function getSessionAwareWebApplicationTrait() + { + return new class () { + use SessionAwareWebApplicationTrait; + + public function getInput(): Input + { + return new Input([]); + } + }; + } + + #[TestDox('Tests a session object is correctly injected into the application and retrieved')] public function testSetSession() { - $object = $this->getMockForTrait(SessionAwareWebApplicationTrait::class); - $mockSession = $this->createMock(SessionInterface::class); + $object = $this->getSessionAwareWebApplicationTrait(); + $mockSession = $this->createStub(SessionInterface::class); $this->assertSame($object, $object->setSession($mockSession), 'The setSession method has a fluent interface.'); $this->assertSame($mockSession, $object->getSession()); } - /** - * @testdox Tests a RuntimeException is thrown when a Session object is not set to the application - * - * @covers Joomla\Application\SessionAwareWebApplicationTrait - */ + #[TestDox('Tests a RuntimeException is thrown when a Session object is not set to the application')] public function testGetSessionForAnException() { $this->expectException(\RuntimeException::class); - $object = $this->getMockForTrait(SessionAwareWebApplicationTrait::class); + $object = $this->getSessionAwareWebApplicationTrait(); $object->getSession(); } - /** - * @testdox Tests the CSRF token can be checked from the `X-CSRF-Token` header - * - * @covers Joomla\Application\SessionAwareWebApplicationTrait - * @uses Joomla\Application\AbstractApplication - * @uses Joomla\Application\AbstractWebApplication - * @uses Joomla\Application\WebApplication - * @uses Joomla\Application\Web\WebClient - * - * @backupGlobals enabled - */ + #[BackupGlobals(true)] + #[TestDox('Tests the CSRF token can be checked from the `X-CSRF-Token` header')] public function testCheckTokenForHttpHeader() { $_SERVER['HTTP_X_CSRF_TOKEN'] = 'token'; - $mockInput = new Input([]); - $mockSession = $this->createMock(SessionInterface::class); $mockSession->expects($this->once()) ->method('getToken') @@ -71,33 +85,18 @@ public function testCheckTokenForHttpHeader() ->with('testing') ->willReturn(true); - $object = $this->getMockForTrait(SessionAwareWebApplicationTrait::class); + $object = $this->getSessionAwareWebApplicationTrait(); $object->setSession($mockSession); - $object->expects($this->any()) - ->method('getInput') - ->willReturn($mockInput); - $this->assertTrue($object->checkToken()); } - /** - * @testdox Tests the CSRF token can be checked from the request body - * - * @covers Joomla\Application\SessionAwareWebApplicationTrait - * @uses Joomla\Application\AbstractApplication - * @uses Joomla\Application\AbstractWebApplication - * @uses Joomla\Application\WebApplication - * @uses Joomla\Application\Web\WebClient - * - * @backupGlobals enabled - */ + #[BackupGlobals(true)] + #[TestDox('Tests the CSRF token can be checked from the request body')] public function testCheckTokenForRequestBody() { $_POST['testing'] = 'token'; - $mockInput = new Input([]); - $mockSession = $this->createMock(SessionInterface::class); $mockSession->expects($this->once()) ->method('getToken') @@ -108,31 +107,16 @@ public function testCheckTokenForRequestBody() ->with('testing') ->willReturn(true); - $object = $this->getMockForTrait(SessionAwareWebApplicationTrait::class); + $object = $this->getSessionAwareWebApplicationTrait(); $object->setSession($mockSession); - $object->expects($this->any()) - ->method('getInput') - ->willReturn($mockInput); - $this->assertTrue($object->checkToken()); } - /** - * @testdox Tests checking the CSRF token fails when it does not exist in the request - * - * @covers Joomla\Application\SessionAwareWebApplicationTrait - * @uses Joomla\Application\AbstractApplication - * @uses Joomla\Application\AbstractWebApplication - * @uses Joomla\Application\WebApplication - * @uses Joomla\Application\Web\WebClient - * - * @backupGlobals enabled - */ + #[BackupGlobals(true)] + #[TestDox('Tests checking the CSRF token fails when it does not exist in the request')] public function testCheckTokenFailsWhenNotPresent() { - $mockInput = new Input([]); - $mockSession = $this->createMock(SessionInterface::class); $mockSession->expects($this->once()) ->method('getToken') @@ -141,13 +125,9 @@ public function testCheckTokenFailsWhenNotPresent() $mockSession->expects($this->never()) ->method('hasToken'); - $object = $this->getMockForTrait(SessionAwareWebApplicationTrait::class); + $object = $this->getSessionAwareWebApplicationTrait(); $object->setSession($mockSession); - $object->expects($this->any()) - ->method('getInput') - ->willReturn($mockInput); - $this->assertFalse($object->checkToken()); } } diff --git a/Tests/Web/WebClientTest.php b/Tests/Web/WebClientTest.php index 832c630a..8dab5f61 100644 --- a/Tests/Web/WebClientTest.php +++ b/Tests/Web/WebClientTest.php @@ -8,15 +8,18 @@ namespace Joomla\Application\Tests\Web; use Joomla\Application\Web\WebClient; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; /** * Test class for Joomla\Application\Web\WebClient. * * @since 1.0.0 - * - * @backupGlobals enabled */ +#[BackupGlobals(true)] +#[CoversClass(WebClient::class)] class WebClientTest extends TestCase { /** @@ -26,7 +29,7 @@ class WebClientTest extends TestCase * * @since 1.0.0 */ - public static function getUserAgentData() + public static function getUserAgentData(): array { // Platform, Mobile, Engine, Browser, Version, User Agent return [ @@ -408,7 +411,7 @@ public static function getUserAgentData() * * @since 1.0.0 */ - public static function getEncodingData() + public static function getEncodingData(): array { // HTTP_ACCEPT_ENCODING, Supported Encodings return [ @@ -429,7 +432,7 @@ public static function getEncodingData() * * @since 1.0.0 */ - public static function getLanguageData() + public static function getLanguageData(): array { // HTTP_ACCEPT_LANGUAGE, Supported Language return [ @@ -450,7 +453,7 @@ public static function getLanguageData() * * @since 1.0.0 */ - public static function detectRobotData() + public static function detectRobotData(): array { return [ ['Googlebot/2.1 (+http://www.google.com/bot.html)', true], @@ -512,10 +515,9 @@ public function setUp(): void * * @return void * - * @dataProvider getUserAgentData * @since 1.0.0 - * @covers \Joomla\Application\Web\WebClient */ + #[DataProvider('getUserAgentData')] public function testDetectBrowser($p, $m, $e, $b, $v, $ua) { $client = new WebClient($ua); @@ -531,7 +533,6 @@ public function testDetectBrowser($p, $m, $e, $b, $v, $ua) * @return void * * @since 1.0.0 - * @covers \Joomla\Application\Web\WebClient */ public function testDetectHeaders() { @@ -553,10 +554,9 @@ public function testDetectHeaders() * * @return void * - * @dataProvider getEncodingData * @since 1.0.0 - * @covers \Joomla\Application\Web\WebClient */ + #[DataProvider('getEncodingData')] public function testDetectEncoding($ae, $e) { $client = new WebClient(null, $ae); @@ -577,10 +577,9 @@ public function testDetectEncoding($ae, $e) * * @return void * - * @dataProvider getUserAgentData * @since 1.0.0 - * @covers \Joomla\Application\Web\WebClient */ + #[DataProvider('getUserAgentData')] public function testDetectEngine($p, $m, $e, $b, $v, $ua) { $client = new WebClient($ua); @@ -597,10 +596,9 @@ public function testDetectEngine($p, $m, $e, $b, $v, $ua) * * @return void * - * @dataProvider getLanguageData * @since 1.0.0 - * @covers \Joomla\Application\Web\WebClient */ + #[DataProvider('getLanguageData')] public function testDetectLanguage($al, $l) { $client = new WebClient(null, null, $al); @@ -621,10 +619,9 @@ public function testDetectLanguage($al, $l) * * @return void * - * @dataProvider getUserAgentData * @since 1.0.0 - * @covers \Joomla\Application\Web\WebClient */ + #[DataProvider('getUserAgentData')] public function testDetectPlatform($p, $m, $e, $b, $v, $ua) { $client = new WebClient($ua); @@ -642,10 +639,9 @@ public function testDetectPlatform($p, $m, $e, $b, $v, $ua) * * @return void * - * @dataProvider detectRobotData * @since 1.0.0 - * @covers \Joomla\Application\Web\WebClient */ + #[DataProvider('detectRobotData')] public function testDetectRobot($userAgent, $expected) { $client = new WebClient($userAgent); diff --git a/Tests/WebApplicationTest.php b/Tests/WebApplicationTest.php index f28287ad..f88f11ac 100644 --- a/Tests/WebApplicationTest.php +++ b/Tests/WebApplicationTest.php @@ -7,28 +7,31 @@ namespace Joomla\Application\Tests; +use Joomla\Application\AbstractApplication; +use Joomla\Application\AbstractWebApplication; use Joomla\Application\Controller\ControllerResolverInterface; +use Joomla\Application\Web\WebClient; use Joomla\Application\WebApplication; use Joomla\Input\Input; use Joomla\Router\ResolvedRoute; use Joomla\Router\RouterInterface; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\TestDox; +use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; /** * Test class for Joomla\Application\WebApplication. - * - * @backupGlobals enabled */ +#[BackupGlobals(true)] +#[CoversClass(WebApplication::class)] +#[UsesClass(AbstractApplication::class)] +#[UsesClass(AbstractWebApplication::class)] +#[UsesClass(WebClient::class)] class WebApplicationTest extends TestCase { - /** - * @testdox Tests that the application is executed successfully. - * - * @covers \Joomla\Application\WebApplication - * @uses \Joomla\Application\AbstractApplication - * @uses \Joomla\Application\AbstractWebApplication - * @uses \Joomla\Application\Web\WebClient - */ + #[TestDox('Tests that the application is executed successfully.')] public function testExecute() { $_SERVER['REQUEST_METHOD'] = 'GET'; diff --git a/composer.json b/composer.json index 8b0f5ce0..dd4b6c66 100644 --- a/composer.json +++ b/composer.json @@ -52,8 +52,8 @@ "joomla/session": "^4.0", "joomla/test": "^4.0", "joomla/uri": "^4.0", - "phpunit/phpunit": "^10.0", - "symfony/phpunit-bridge": "^7.0", + "phpunit/phpunit": "^12.5 || ^13.0", + "symfony/phpunit-bridge": "^7.0 || ^8.0", "squizlabs/php_codesniffer": "^4.0", "phpstan/phpstan": "^2.1.17", "phpstan/phpstan-deprecation-rules": "^2.0.3" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 18cd6a92..2ce3a57f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,14 +1,11 @@ - - - - Tests - - - - - + + + + Tests + + + + +