From 5fee7d9c5099b88eb77ea40c1af52a0cbb63aef5 Mon Sep 17 00:00:00 2001 From: Bruno FG Date: Sun, 1 Oct 2023 12:04:47 +1100 Subject: [PATCH] Update Plugins_Factory_Test to actually test the factory --- tests/unit/Plugin_Factory_Test.php | 41 +++++------------------------- 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/tests/unit/Plugin_Factory_Test.php b/tests/unit/Plugin_Factory_Test.php index 90ae381..d94b9eb 100644 --- a/tests/unit/Plugin_Factory_Test.php +++ b/tests/unit/Plugin_Factory_Test.php @@ -4,7 +4,6 @@ namespace WordPress_Related\Tests\Unit; -use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\TestCase; use WordPress_Related\Plugin_Factory; use DI\Container; @@ -16,45 +15,19 @@ */ class Plugin_Factory_Test extends TestCase { - /** - * Container. - * - * @since 1.0.0 - * @var Container - */ - protected Container $container; - - /** - * Set up. - * - * @return void - * @throws Exception - * @since 1.0.0 - */ - public function setUp(): void { - parent::setUp(); - $this->container = $this->createMock( 'DI\Container' ); - } - /** * Test plugin factory create. * * @return void - * @since 1.0.0 */ public function test_plugin_factory_create(): void { - $plugin = Plugin_Factory::create( $this->container ); - $this->assertInstanceOf( 'WordPress_Related\Plugin', $plugin ); - } + $container = $this->createMock( Container::class ); - /** - * Tear down. - * - * @return void - * @since 1.0.0 - */ - public function tearDown(): void { - parent::tearDown(); - unset( $this->container ); + $plugin_instance_one = Plugin_Factory::create( $container ); + $plugin_instance_two = Plugin_Factory::create( $container ); + + $this->assertInstanceOf( 'WordPress_Related\Plugin', $plugin_instance_one ); + $this->assertInstanceOf( 'WordPress_Related\Plugin', $plugin_instance_two ); + $this->assertSame( $plugin_instance_one, $plugin_instance_two ); } }