You are here

public function ServicesUITest::testEndpointMenu in Services 7.3

Test that adding a menu endpoint creates an menu path for that item.

File

tests/ui/ServicesUITests.test, line 75
Tests for UI of Services.

Class

ServicesUITest
@file Tests for UI of Services.

Code

public function testEndpointMenu() {

  // Create the endpoint.
  $endpoint_settings = array(
    'name' => 'machine_name',
    'path' => $this
      ->randomName(10),
    'server' => 'rest_server',
  );
  $this
    ->drupalPost('admin/structure/services/add', $endpoint_settings, 'Save');
  $this
    ->assertResponse('200', 'Create Endpoint.');

  // Enable node resource index method.
  $resource_settings = array(
    'resources[node][operations][index][enabled]' => '1',
  );
  $this
    ->drupalPost('admin/structure/services/list/' . $endpoint_settings['name'] . '/resources', $resource_settings, 'Save');
  $this
    ->assertResponse('200', 'Node resource index method enabled successfully.');

  // Check path.
  $this
    ->drupalGet($endpoint_settings['path'] . '/node');
  $this
    ->assertResponse('200', 'Accessed endpoint menu path node index method.');

  // After accessing node resource we got logged out. So we login again.
  $this
    ->drupalLogin($this->privilegedUser);

  // Check edit.
  $this
    ->drupalGet('admin/structure/services/list/' . $endpoint_settings['name'] . '/edit');
  $this
    ->assertResponse('200', 'Access endpoint edit path.');

  // Check export.
  $this
    ->drupalGet('admin/structure/services/list/' . $endpoint_settings['name'] . '/export');
  $this
    ->assertResponse('200', 'Access endpoint export path.');

  // Check delete.
  $this
    ->drupalGet('admin/structure/services/list/' . $endpoint_settings['name'] . '/delete');
  $this
    ->assertResponse('200', 'Access endpoint delete path.');
}