27 parent::tearDown(); |
27 parent::tearDown(); |
28 } |
28 } |
29 |
29 |
30 public function testIndexQuery() { |
30 public function testIndexQuery() { |
31 |
31 |
32 $query = preg_replace('/\s+/', ' ', "select (?o as ?theme) (COUNT(?s) as ?count) where { |
32 $query = preg_replace('/\s+/', ' ', "select (?o as ?theme) (COUNT(?s) as ?count) where { |
33 ?s a <http://www.europeana.eu/schemas/edm/ProvidedCHO> . |
33 ?s a <http://www.europeana.eu/schemas/edm/ProvidedCHO> . |
34 ?s <http://purl.org/dc/elements/1.1/subject> ?o . |
34 ?s <http://purl.org/dc/elements/1.1/subject> ?o . |
35 FILTER (isIRI(?o) && regex(str(?o), '^".config('corpusparole.bnf_ark_base_url')."')) . |
35 FILTER (isIRI(?o) && regex(str(?o), '^".config('corpusparole.bnf_ark_base_url')."')) . |
36 } |
36 } |
37 GROUP BY ?o |
37 GROUP BY ?o |
45 $this->get('/api/v1/themes/'); |
45 $this->get('/api/v1/themes/'); |
46 } |
46 } |
47 |
47 |
48 public function testIndexQueryBnf() { |
48 public function testIndexQueryBnf() { |
49 |
49 |
50 $query = preg_replace('/\s+/', ' ', "select (?o as ?theme) (COUNT(?s) as ?count) where { |
50 $query = preg_replace('/\s+/', ' ', "select (?o as ?theme) (COUNT(?s) as ?count) where { |
51 ?s a <http://www.europeana.eu/schemas/edm/ProvidedCHO> . |
51 ?s a <http://www.europeana.eu/schemas/edm/ProvidedCHO> . |
52 ?s <http://purl.org/dc/elements/1.1/subject> ?o . |
52 ?s <http://purl.org/dc/elements/1.1/subject> ?o . |
53 FILTER (isIRI(?o) && regex(str(?o), '^".config('corpusparole.bnf_ark_base_url')."')) . |
53 FILTER (isIRI(?o) && regex(str(?o), '^".config('corpusparole.bnf_ark_base_url')."')) . |
54 } |
54 } |
55 GROUP BY ?o |
55 GROUP BY ?o |
64 } |
64 } |
65 |
65 |
66 |
66 |
67 public function testIndexQueryAll() { |
67 public function testIndexQueryAll() { |
68 |
68 |
69 $query = preg_replace('/\s+/', ' ', "select (?o as ?theme) (COUNT(?s) as ?count) where { |
69 $query = preg_replace('/\s+/', ' ', "select (?o as ?theme) (COUNT(?s) as ?count) where { |
70 ?s a <http://www.europeana.eu/schemas/edm/ProvidedCHO> . |
70 ?s a <http://www.europeana.eu/schemas/edm/ProvidedCHO> . |
71 ?s <http://purl.org/dc/elements/1.1/subject> ?o . |
71 ?s <http://purl.org/dc/elements/1.1/subject> ?o . |
72 } |
72 } |
73 GROUP BY ?o |
73 GROUP BY ?o |
74 ORDER BY DESC(?count)"); |
74 ORDER BY DESC(?count)"); |
80 ->andReturn(new \ArrayIterator([])); |
80 ->andReturn(new \ArrayIterator([])); |
81 $this->get('/api/v1/themes/?filter=all'); |
81 $this->get('/api/v1/themes/?filter=all'); |
82 } |
82 } |
83 |
83 |
84 |
84 |
85 public function testIndexQueryNone() { |
85 public function testIndexQueryNone() { |
86 |
86 |
87 $query = preg_replace('/\s+/', ' ', "select (?o as ?theme) (COUNT(?s) as ?count) where { |
87 $query = preg_replace('/\s+/', ' ', "select (?o as ?theme) (COUNT(?s) as ?count) where { |
88 ?s a <http://www.europeana.eu/schemas/edm/ProvidedCHO> . |
88 ?s a <http://www.europeana.eu/schemas/edm/ProvidedCHO> . |
89 ?s <http://purl.org/dc/elements/1.1/subject> ?o . |
89 ?s <http://purl.org/dc/elements/1.1/subject> ?o . |
90 } |
90 } |
91 GROUP BY ?o |
91 GROUP BY ?o |
92 ORDER BY DESC(?count)"); |
92 ORDER BY DESC(?count)"); |
146 (object)['theme'=>new Resource('http://ark.bnf.fr/ark:/12148/cb119339867'), 'count' => Literal::create(33)], |
146 (object)['theme'=>new Resource('http://ark.bnf.fr/ark:/12148/cb119339867'), 'count' => Literal::create(33)], |
147 (object)['theme'=>Literal::create('Français', 'fr'), 'count' => Literal::create(22)], |
147 (object)['theme'=>Literal::create('Français', 'fr'), 'count' => Literal::create(22)], |
148 ])); |
148 ])); |
149 $this->get('/api/v1/themes/')->assertTrue($this->response->isOk(), $this->response->content()); |
149 $this->get('/api/v1/themes/')->assertTrue($this->response->isOk(), $this->response->content()); |
150 $this->seeJsonEquals(["themes" => [ |
150 $this->seeJsonEquals(["themes" => [ |
151 "http://lexvo.org/id/iso639-3/gsw" => ["url" => "http://lexvo.org/id/iso639-3/gsw", "label" => null, "count" => 44], |
151 "http://lexvo.org/id/iso639-3/gsw" => ["label" => "alémanique", "count" => 44], |
152 "http://ark.bnf.fr/ark:/12148/cb119339867" => ["url" => "http://ark.bnf.fr/ark:/12148/cb119339867", "label" => null, "count" => 33], |
152 "http://ark.bnf.fr/ark:/12148/cb119339867" => ["label" => "famille", "count" => 33], |
153 "Français" => ["url" => null, "label" => "Français", "count" => 22], |
153 "Français" => ["label" => "Français", "count" => 22], |
154 ]]); |
154 ]]); |
155 } |
155 } |
156 } |
156 } |