}
/**
- * Test getLinks with private attribute to 1 or true.
+ * Test getLinks with visibility parameter set to all
*/
- public function testGetLinksPrivate()
+ public function testGetLinksVisibilityAll()
{
- $env = Environment::mock([
- 'REQUEST_METHOD' => 'GET',
- 'QUERY_STRING' => 'private=true'
- ]);
+ $env = Environment::mock(
+ [
+ 'REQUEST_METHOD' => 'GET',
+ 'QUERY_STRING' => 'visibility=all'
+ ]
+ );
$request = Request::createFromEnvironment($env);
$response = $this->controller->getLinks($request, new Response());
$this->assertEquals(200, $response->getStatusCode());
- $data = json_decode((string) $response->getBody(), true);
- $this->assertEquals($this->refDB->countPrivateLinks(), count($data));
- $this->assertEquals(6, $data[0]['id']);
+ $data = json_decode((string)$response->getBody(), true);
+ $this->assertEquals($this->refDB->countLinks(), count($data));
+ $this->assertEquals(41, $data[0]['id']);
$this->assertEquals(self::NB_FIELDS_LINK, count($data[0]));
+ }
+ /**
+ * Test getLinks with visibility parameter set to private
+ */
+ public function testGetLinksVisibilityPrivate()
+ {
$env = Environment::mock([
'REQUEST_METHOD' => 'GET',
- 'QUERY_STRING' => 'private=1'
+ 'QUERY_STRING' => 'visibility=private'
]);
$request = Request::createFromEnvironment($env);
$response = $this->controller->getLinks($request, new Response());
}
/**
- * Test getLinks with private attribute to false or 0
+ * Test getLinks with visibility parameter set to public
*/
- public function testGetLinksNotPrivate()
+ public function testGetLinksVisibilityPublic()
{
$env = Environment::mock(
[
'REQUEST_METHOD' => 'GET',
- 'QUERY_STRING' => 'private=0'
- ]
- );
- $request = Request::createFromEnvironment($env);
- $response = $this->controller->getLinks($request, new Response());
- $this->assertEquals(200, $response->getStatusCode());
- $data = json_decode((string)$response->getBody(), true);
- $this->assertEquals($this->refDB->countLinks(), count($data));
- $this->assertEquals(41, $data[0]['id']);
- $this->assertEquals(self::NB_FIELDS_LINK, count($data[0]));
-
- $env = Environment::mock(
- [
- 'REQUEST_METHOD' => 'GET',
- 'QUERY_STRING' => 'private=false'
+ 'QUERY_STRING' => 'visibility=public'
]
);
$request = Request::createFromEnvironment($env);
$response = $this->controller->getLinks($request, new Response());
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode((string)$response->getBody(), true);
- $this->assertEquals($this->refDB->countLinks(), count($data));
+ $this->assertEquals($this->refDB->countPublicLinks(), count($data));
$this->assertEquals(41, $data[0]['id']);
$this->assertEquals(self::NB_FIELDS_LINK, count($data[0]));
}