You are here

public function GeolocationViewsProximityByEntityTest::testProximityByEntity in Geolocation Field 8.3

Same name and namespace in other branches
  1. 8 tests/src/Functional/GeolocationViewsProximityByEntityTest.php \Drupal\Tests\geolocation\Functional\GeolocationViewsProximityByEntityTest::testProximityByEntity()
  2. 8.2 tests/src/Functional/GeolocationViewsProximityByEntityTest.php \Drupal\Tests\geolocation\Functional\GeolocationViewsProximityByEntityTest::testProximityByEntity()

Tests the proximity sort.

File

tests/src/Functional/GeolocationViewsProximityByEntityTest.php, line 45

Class

GeolocationViewsProximityByEntityTest
Tests the proximity views sort.

Namespace

Drupal\Tests\geolocation\Functional

Code

public function testProximityByEntity() {

  /** @var \Drupal\node\NodeStorageInterface $entity_test_storage */
  $entity_test_storage = \Drupal::entityTypeManager()
    ->getStorage('node');
  $origin_node = $entity_test_storage
    ->create([
    'id' => 1,
    'title' => 'Proximity Origin Node',
    'body' => 'test test',
    'type' => 'geolocation_default_article',
    'field_geolocation_demo_single' => [
      'lat' => 52,
      'lng' => 47,
    ],
  ]);
  $origin_node
    ->save();
  $entity_test_storage
    ->create([
    'title' => 'Closest Node',
    'body' => 'bar test',
    'type' => 'geolocation_default_article',
    'field_geolocation_demo_single' => [
      'lat' => 53,
      'lng' => 48,
    ],
  ])
    ->save();
  $this
    ->drupalGet('geolocation-demo/proximity-by-entity-id/' . $origin_node
    ->id());
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->responseNotContains('Proximity Origin Node');
  $this
    ->assertSession()
    ->responseContains('Closest Node');
  $this
    ->assertSession()
    ->responseContains('130.18');
}