server/src/tests/Controllers/DiscourseControllerTest.php
changeset 314 f5690d918358
parent 306 3fccf43160a7
child 319 78990a8a069b
equal deleted inserted replaced
313:706f10bcdc3c 314:f5690d918358
    40         $this->sparqlClient
    40         $this->sparqlClient
    41             ->shouldReceive('query')
    41             ->shouldReceive('query')
    42             ->with($query)
    42             ->with($query)
    43             ->once()
    43             ->once()
    44             ->andReturn(new \ArrayIterator([]));
    44             ->andReturn(new \ArrayIterator([]));
    45         $this->get('/api/v1/discourses/');
    45         $this->get('/api/v1/stats/discourses/');
    46     }
    46     }
    47 
    47 
    48     public function testIndex() {
    48     public function testIndex() {
    49 
    49 
    50         $this->sparqlClient
    50         $this->sparqlClient
    53             ->andReturn(new \ArrayIterator([
    53             ->andReturn(new \ArrayIterator([
    54                 (object)['res'=>new Resource('http://ark.bnf.fr/ark:/12148/cb12083158d'), 'count' => Literal::create(44)],
    54                 (object)['res'=>new Resource('http://ark.bnf.fr/ark:/12148/cb12083158d'), 'count' => Literal::create(44)],
    55                 (object)['res'=>new Resource('http://ark.bnf.fr/ark:/12148/cb119783362'), 'count' => Literal::create(33)],
    55                 (object)['res'=>new Resource('http://ark.bnf.fr/ark:/12148/cb119783362'), 'count' => Literal::create(33)],
    56                 (object)['res'=>new Resource('http://ark.bnf.fr/ark:/12148/cb13319048g'), 'count' => Literal::create(22)],
    56                 (object)['res'=>new Resource('http://ark.bnf.fr/ark:/12148/cb13319048g'), 'count' => Literal::create(22)],
    57             ]));
    57             ]));
    58         $this->get('/api/v1/discourses/')->assertTrue($this->response->isOk(), $this->response->content());
    58         $this->get('/api/v1/stats/discourses/')->assertTrue($this->response->isOk(), $this->response->content());
    59         $this->seeJsonEquals(["discourses" => [
    59         $this->seeJsonEquals(["discourses" => [
    60             "http://ark.bnf.fr/ark:/12148/cb12083158d" => ["label" => "argumentation", "count" => 44],
    60             "http://ark.bnf.fr/ark:/12148/cb12083158d" => ["label" => "argumentation", "count" => 44],
    61             "http://ark.bnf.fr/ark:/12148/cb119783362" => ["label" => "bavardage", "count" => 33],
    61             "http://ark.bnf.fr/ark:/12148/cb119783362" => ["label" => "bavardage", "count" => 33],
    62             "http://ark.bnf.fr/ark:/12148/cb13319048g" => ["label" => "chansons", "count" => 22],
    62             "http://ark.bnf.fr/ark:/12148/cb13319048g" => ["label" => "chansons", "count" => 22],
    63         ]]);
    63         ]]);