From d0c8cde59cbeb587a88c929444d029d2c071961b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lys=C3=BD?= Date: Mon, 4 Nov 2024 12:21:28 +0100 Subject: [PATCH] Migrate tests/unit folder to WordPress Coding Standard [MAILPOET-6240] --- packages/php/email-editor/phpcs.xml | 5 +++ .../tests/unit/Container_Test.php | 28 +++++++++--- .../email-editor/tests/unit/_bootstrap.php | 31 +++++++++++-- .../php/email-editor/tests/unit/_stubs.php | 43 +++++++++++++------ 4 files changed, 87 insertions(+), 20 deletions(-) diff --git a/packages/php/email-editor/phpcs.xml b/packages/php/email-editor/phpcs.xml index aea236529a..918a9146c4 100644 --- a/packages/php/email-editor/phpcs.xml +++ b/packages/php/email-editor/phpcs.xml @@ -11,6 +11,11 @@ tests/* + + + tests/unit/_bootstrap.php + + vendor/* diff --git a/packages/php/email-editor/tests/unit/Container_Test.php b/packages/php/email-editor/tests/unit/Container_Test.php index 4f5a212508..c3e52de5af 100644 --- a/packages/php/email-editor/tests/unit/Container_Test.php +++ b/packages/php/email-editor/tests/unit/Container_Test.php @@ -1,12 +1,24 @@ -assertInstanceOf( stdClass::class, $service ); } + /** + * Test if sets and gets service with dependencies. + */ public function testGetReturnsSameInstance(): void { $container = new Container(); @@ -32,19 +47,22 @@ class Container_Test extends TestCase { } ); - // Retrieve the service twice + // Retrieve the service twice. $service1 = $container->get( 'singleton_service' ); $service2 = $container->get( 'singleton_service' ); - // Check that both instances are the same + // Check that both instances are the same. $this->assertSame( $service1, $service2 ); } + /** + * Test if it throws exception for non-existing service. + */ public function testExceptionForNonExistingService(): void { - // Create the container instance + // Create the container instance. $container = new Container(); - // Attempt to get a non-existing service should throw an exception + // Attempt to get a non-existing service should throw an exception. $this->expectException( Exception::class ); $this->expectExceptionMessage( 'Service not found: non_existing_service' ); diff --git a/packages/php/email-editor/tests/unit/_bootstrap.php b/packages/php/email-editor/tests/unit/_bootstrap.php index 3d470608fb..c853a6e15a 100644 --- a/packages/php/email-editor/tests/unit/_bootstrap.php +++ b/packages/php/email-editor/tests/unit/_bootstrap.php @@ -1,16 +1,41 @@ -