Skip to content

Commit

Permalink
test adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
pwtyler committed Nov 12, 2024
1 parent f9bbd8b commit 2ebc484
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions tests/Unit/EndpointServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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.
*
Expand All @@ -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());
Expand All @@ -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());
}

Expand Down

0 comments on commit 2ebc484

Please sign in to comment.