You are here

function SearchByPageUnitTest::testPathParts in Search by Page 8

Tests the search_by_page_path_parts() function.

File

tests/src/Unit/SearchByPageUnitTest.php, line 37
Tests for the Search by Page module. By Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com

Class

SearchByPageUnitTest
Unit tests for Search by Page functions.

Namespace

Drupal\Tests\search_by_page\Unit

Code

function testPathParts() {
  $path = "abc/def?a=b&c=f";
  $res = \Drupal::service('search_by_page.settings')
    ->explodePathParts($path);
  $this
    ->assertEquals(count($res), 2, "\\Drupal::service('search_by_page.settings')->explodePathParts() returns right count in results");
  $this
    ->assertEquals($res[0], 'abc/def', "\\Drupal::service('search_by_page.settings')->explodePathParts() returns right base path");
  $this
    ->assertEquals($res[1], 'a=b&c=f', "\\Drupal::service('search_by_page.settings')->explodePathParts() returns right query part");
  $path = "abc/def";
  $res = \Drupal::service('search_by_page.settings')
    ->explodePathParts($path);
  $this
    ->assertEquals(count($res), 1, "\\Drupal::service('search_by_page.settings')->explodePathParts() returns right count in results");
  $this
    ->assertEquals($res[0], 'abc/def', "\\Drupal::service('search_by_page.settings')->explodePathParts() returns right base path");
  $path = "abc/def&a=b&c=f";
  $res = \Drupal::service('search_by_page.settings')
    ->explodePathParts($path);
  $this
    ->assertEquals(count($res), 2, "\\Drupal::service('search_by_page.settings')->explodePathParts() returns right count in results");
  $this
    ->assertEquals($res[0], 'abc/def', "\\Drupal::service('search_by_page.settings')->explodePathParts() returns right base path");
  $this
    ->assertEquals($res[1], 'a=b&c=f', "\\Drupal::service('search_by_page.settings')->explodePathParts() returns right query part");
}