Skip to content

Commit

Permalink
UHF-10990: Kernel test
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrsky committed Nov 21, 2024
1 parent 4b420cc commit 83ad282
Showing 1 changed file with 7 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
namespace Drupal\Tests\helfi_api_base\Functional;

use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Url;
use Drupal\elasticsearch_connector\Plugin\search_api\backend\ElasticSearchBackend;
use Drupal\helfi_api_base\Plugin\ElasticSearch\Connector\HelfiConnector;
use Drupal\KernelTests\KernelTestBase;
use Elastic\Elasticsearch\Client;

/**
* Test for elasticsearch connector plugin.
*/
class ElasticsearchConnectorTest extends BrowserTestBase {
class ElasticsearchConnectorTest extends KernelTestBase {

/**
* {@inheritdoc}
Expand All @@ -23,23 +24,13 @@ class ElasticsearchConnectorTest extends BrowserTestBase {
'helfi_api_base',
];

/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';

/**
* {@inheritdoc}
*/
public function setUp(): void {
parent::setUp();

// Create an admin user.
$admin_user = $this->drupalCreateUser([
'access administration pages',
'administer search_api',
]);
$this->drupalLogin($admin_user);
$this->installEntitySchema('search_api_server');
}

/**
Expand Down Expand Up @@ -73,14 +64,9 @@ public function testSearchApiConnector() {

$backend = $server->getBackend();
assert($backend instanceof ElasticSearchBackend);
$this->assertInstanceOf(HelfiConnector::class, $backend->getConnector());

$assert_session = $this->assertSession();
$this->drupalGet(Url::fromRoute('entity.search_api_server.edit_form', [
'search_api_server' => 'default',
]));
$assert_session->statusCodeEquals(200);
$assert_session->pageTextContains('Helfi Connector');
$connector = $backend->getConnector();
$this->assertInstanceOf(HelfiConnector::class, $connector);
$this->assertInstanceOf(Client::class, $connector->getClient());
}

}

0 comments on commit 83ad282

Please sign in to comment.