public function test_get_namespace_index()
{
$server = new WP_REST_Server();
$server->register_route('test/example', '/test/example/some-route', array(array('methods' => WP_REST_Server::READABLE, 'callback' => '__return_true'), array('methods' => WP_REST_Server::DELETABLE, 'callback' => '__return_true')));
$server->register_route('test/another', '/test/another/route', array(array('methods' => WP_REST_Server::READABLE, 'callback' => '__return_false')));
$request = new WP_REST_Request();
$request->set_param('namespace', 'test/example');
$index = rest_ensure_response($server->get_namespace_index($request));
$data = $index->get_data();
// Check top-level.
$this->assertEquals('test/example', $data['namespace']);
$this->assertArrayHasKey('routes', $data);
// Check we have the route we expect...
$this->assertArrayHasKey('/test/example/some-route', $data['routes']);
// ...and none we don't.
$this->assertArrayNotHasKey('/test/another/route', $data['routes']);
}