localgov_events-3.0.5/tests/src/Functional/LocalgovIntegrationTest.php
tests/src/Functional/LocalgovIntegrationTest.php
<?php
namespace Drupal\Tests\localgov_events\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\Traits\Core\CronRunTrait;
use Drupal\Tests\node\Traits\NodeCreationTrait;
use Drupal\Tests\system\Functional\Menu\AssertBreadcrumbTrait;
use Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait;
use Drupal\node\NodeInterface;
/**
* Tests pages working together with search, pathauto, services and topics.
*
* @group localgov_step_by_step
*/
class LocalgovIntegrationTest extends BrowserTestBase {
use NodeCreationTrait;
use AssertBreadcrumbTrait;
use TaxonomyTestTrait;
use CronRunTrait;
/**
* Skip schema checks.
*
* @var string[]
*/
protected static $configSchemaCheckerExclusions = [
// Missing schema:
// - 'content.location.settings.reset_map.position'.
// - 'content.location.settings.weight'.
'core.entity_view_display.localgov_geo.area.default',
'core.entity_view_display.localgov_geo.area.embed',
'core.entity_view_display.localgov_geo.area.full',
'core.entity_view_display.geo_entity.area.default',
'core.entity_view_display.geo_entity.area.embed',
'core.entity_view_display.geo_entity.area.full',
// Missing schema:
// - content.location.settings.geometry_validation.
// - content.location.settings.multiple_map.
// - content.location.settings.leaflet_map.
// - content.location.settings.height.
// - content.location.settings.height_unit.
// - content.location.settings.hide_empty_map.
// - content.location.settings.disable_wheel.
// - content.location.settings.gesture_handling.
// - content.location.settings.popup.
// - content.location.settings.popup_content.
// - content.location.settings.leaflet_popup.
// - content.location.settings.leaflet_tooltip.
// - content.location.settings.map_position.
// - content.location.settings.weight.
// - content.location.settings.icon.
// - content.location.settings.leaflet_markercluster.
// - content.location.settings.feature_properties.
'core.entity_form_display.geo_entity.address.default',
'core.entity_form_display.geo_entity.address.inline',
// Missing schema:
// - content.postal_address.settings.providers.
// - content.postal_address.settings.geocode_geofield.
'core.entity_form_display.localgov_geo.address.default',
'core.entity_form_display.localgov_geo.address.inline',
];
/**
* Test breadcrumbs in the Standard profile.
*
* @var string
*/
protected $profile = 'testing';
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* A user with permission to bypass content access checks.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
/**
* The node storage.
*
* @var \Drupal\node\NodeStorageInterface
*/
protected $nodeStorage;
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'localgov_core',
'localgov_topics',
'localgov_events',
'localgov_search',
'localgov_search_db',
];
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$this->drupalPlaceBlock('system_breadcrumb_block');
$this->adminUser = $this->drupalCreateUser([
'bypass node access',
'administer nodes',
]);
$this->nodeStorage = $this->container->get('entity_type.manager')->getStorage('node');
}
/**
* LocalGov Search integration.
*/
public function testLocalgovSearch() {
$body = [
'value' => 'Science is the search for truth, that is the effort to understand the world: it involves the rejection of bias, of dogma, of revelation, but not the rejection of morality.',
'summary' => 'One of the greatest joys known to man is to take a flight into ignorance in search of knowledge.',
];
$this->createNode([
'title' => 'Test Event',
'body' => $body,
'type' => 'localgov_event',
'status' => NodeInterface::PUBLISHED,
'localgov_event_date' => [
'value' => '2024-03-01T00:00:00',
'end_value' => '2024-03-01T01:00:00',
'rrule' => NULL,
'timezone' => 'Europe/London',
'infinite' => 0,
],
]);
$this->cronRun();
$this->drupalGet('search', ['query' => ['s' => 'bias+dogma+revelation']]);
$this->assertSession()->pageTextContains('Test Event');
$this->assertSession()->responseContains('<strong>bias</strong>');
$this->assertSession()->responseContains('<strong>dogma</strong>');
$this->assertSession()->responseContains('<strong>revelation</strong>');
}
}
