From 2ebc484cb806e85a04f194ccbfea6bc8df54b62e Mon Sep 17 00:00:00 2001 From: Phil Tyler Date: Tue, 12 Nov 2024 13:31:15 -0800 Subject: [PATCH] test adjust --- tests/Unit/EndpointServiceTest.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/tests/Unit/EndpointServiceTest.php b/tests/Unit/EndpointServiceTest.php index 07c23911..e2bc35ab 100644 --- a/tests/Unit/EndpointServiceTest.php +++ b/tests/Unit/EndpointServiceTest.php @@ -3,6 +3,7 @@ namespace Drupal\search_api_pantheon\tests\Unit; use Drupal\search_api_pantheon\Services\Endpoint; +use Drupal\Core\Entity\EntityTypeManagerInterface; use PHPUnit\Framework\TestCase; /** @@ -12,6 +13,23 @@ */ class EndpointServiceTest extends TestCase { + protected $entityTypeManager; + + protected function setUp(): void { + parent::setUp(); + + // Mock the EntityTypeManagerInterface. + $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class); + + // Define any specific behavior for methods you expect to call. + // For example, if you are loading storage for a particular entity type: + // $storageMock = $this->createMock(EntityStorageInterface::class); + // $this->entityTypeManager + // ->method('getStorage') + // ->with('search_api_server') + // ->willReturn($storageMock); + } + /** * Test the endpoint class's ability to generate correct URL's. * @@ -29,7 +47,7 @@ public function testURIGeneration() { 'collection' => NULL, 'leader' => FALSE, 'reload_path' => "/reload-path", - ]); + ], $this->entityTypeManager); $this->assertEquals('/core-name', $ep->getCore()); $this->assertEquals('server-path', $ep->getPath()); @@ -49,13 +67,13 @@ public function testURIGeneration() { $ep->getSchemaUploadUri() ); $this->assertEquals( - 'one://two:1234/server-path/schema-path/reload-path', + 'one://two:1234/server-path/reload-path', $ep->getReloadUri() ); } public function testReloadPath() { - $ep = new Endpoint(["reload_path" => "/reload"]); + $ep = new Endpoint(["reload_path" => "/reload"], $this->entityTypeManager); $this->assertEquals("/reload", $ep->getReloadPath()); }