enableEndpoint example

/** * Test core functions of the linkset endpoint. * * Not intended to test every feature of the endpoint, only the most basic * functionality. * * The expected linkset also ensures that path aliasing is working properly. * * @throws \Exception */
  public function testBasicFunctions() {
    $this->enableEndpoint(TRUE);
    $expected_linkset = $this->getReferenceLinksetDataFromFile(__DIR__ . '/../../../fixtures/linkset/linkset-menu-main.json');
    $response = $this->doRequest('GET', Url::fromUri('base:/system/menu/main/linkset'));
    $this->assertSame('application/linkset+json', $response->getHeaderLine('content-type'));
    $this->assertSame($expected_linkset, Json::decode((string) $response->getBody()));
    $this->doRequest('GET', Url::fromUri('base:/system/menu/missing/linkset'), 404);
  }

  /** * Test the cacheability of the linkset endpoint. * * This test's purpose is to ensure that the menu linkset response is properly * cached. It does this by sending a request and validating it has a cache * miss and the correct cacheability meta, then by sending the same request to * assert a cache hit. Finally, a new menu item is created to ensure that the * cached response is properly invalidated. */
Home | Imprint | This part of the site doesn't use cookies.