self::ENDPOINT_NAME ); $response = dokuwiki_plugin_api_util::getRequest($queryParameters); $data = self::$JSON->decode($response->getContent()); /** * Test */ // Two pages // Due to concurrent test, we can have more than this two pages ... // Wee check that they are in the index $pagesFoundCounter = 0; $pagesToFound = array($homePageId, $secondPage); foreach ($data as $page) { // Same Id if (in_array($page['id'], $pagesToFound)) { $pagesFoundCounter++; } if ($page['id'] == $homePageId) { // Same Title $actualPageTitle = $page['title']; $expectedTitle = $homePageId; $this->assertEquals($expectedTitle, $actualPageTitle, "A page title without header must be the page id"); } if ($page['id'] ==$secondPage) { $actualPageTitle = $page['title']; $expectedTitle = $secondPageTitle; $this->assertEquals($expectedTitle, $actualPageTitle, "A page title with header must be the first heading"); } } $this->assertEquals(sizeof($pagesToFound), $pagesFoundCounter, "The two pages were found"); } /** * Test the max pages parameters */ public function test_plugin_pages_limit() { /** * Set things up */ // Create 10 pages for ($i = 1; $i <= 10; $i++) { saveWikiText($i, 'Text for the page ' . $i, "summary for page " . $i); idx_addPage($i); } /** * Query */ $limit = 3; $queryParameters = array( 'fn' => 'pages', 'limit' => $limit ); $response = dokuwiki_plugin_api_util::getRequest($queryParameters); $data = self::$JSON->decode($response->getContent()); /** * Test */ // Max pages $this->assertEquals($limit, sizeof($data), "The number of page is equal t max"); } }