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()); }