diff --git a/Tests/AbstractControllerTest.php b/Tests/AbstractControllerTest.php index a1dad3f0..7cee25e3 100644 --- a/Tests/AbstractControllerTest.php +++ b/Tests/AbstractControllerTest.php @@ -10,18 +10,20 @@ use Joomla\Application\AbstractApplication; use Joomla\Controller\AbstractController; use Joomla\Input\Input; -use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\TestCase; /** * Tests for the Joomla\Controller\AbstractController class. */ +#[CoversClass(AbstractController::class)] class AbstractControllerTest extends TestCase { /** * Object being tested * - * @var MockObject|AbstractController + * @var AbstractController */ private $instance; @@ -35,53 +37,37 @@ protected function setUp(): void $this->instance = new TestController(); } - /** - * @testdox Tests the controller is instantiated correctly - * - * @covers Joomla\Controller\AbstractController - */ + #[TestDox('Tests the controller is instantiated correctly')] public function test__constructDefaultBehaviour() { $this->assertNull($this->instance->getApplication()); $this->assertNull($this->instance->getInput()); } - /** - * @testdox Tests the controller is instantiated correctly - * - * @covers Joomla\Controller\AbstractController - */ + #[TestDox('Tests the controller is instantiated correctly')] public function test__constructDependencyInjection() { - $mockInput = $this->createMock(Input::class); - $mockApp = $this->createMock(AbstractApplication::class); - $object = new TestController($mockInput, $mockApp); + $mockInput = $this->createStub(Input::class); + $mockApp = $this->createStub(AbstractApplication::class); + $object = new TestController($mockInput, $mockApp); $this->assertSame($mockApp, $object->getApplication()); $this->assertSame($mockInput, $object->getInput()); } - /** - * @testdox Tests an application object is injected into the controller and retrieved correctly - * - * @covers Joomla\Controller\AbstractController - */ + #[TestDox('Tests an application object is injected into the controller and retrieved correctly')] public function testSetAndGetApplication() { - $mockApp = $this->createMock(AbstractApplication::class); + $mockApp = $this->createStub(AbstractApplication::class); $this->assertSame($this->instance, $this->instance->setApplication($mockApp), 'The setApplication method has a fluent interface'); $this->assertSame($mockApp, $this->instance->getApplication()); } - /** - * @testdox Tests an input object is injected into the controller and retrieved correctly - * - * @covers Joomla\Controller\AbstractController - */ + #[TestDox('Tests an input object is injected into the controller and retrieved correctly')] public function testSetAndGetInput() { - $mockInput = $this->createMock(Input::class); + $mockInput = $this->createStub(Input::class); $this->assertSame($this->instance, $this->instance->setInput($mockInput), 'The setInput method has a fluent interface'); $this->assertSame($mockInput, $this->instance->getInput()); @@ -96,7 +82,8 @@ public function testSetAndGetInput() * @package Joomla\Controller\Tests * @since 1.0 */ -class TestController extends AbstractController { +class TestController extends AbstractController +{ public function execute() { // TODO: Implement execute() method.