author | ymh <ymh.work@gmail.com> |
Mon, 16 Oct 2017 15:22:08 +0200 | |
changeset 552 | 2c579ea45608 |
parent 537 | d2e6ee099125 |
permissions | -rw-r--r-- |
23 | 1 |
<?php |
2 |
||
3 |
use Mockery as m; |
|
4 |
||
5 |
use CorpusParole\Services\ViafResolverException; |
|
6 |
||
7 |
/** |
|
8 |
* |
|
9 |
*/ |
|
10 |
class ViafControllerTest extends TestCase { |
|
11 |
||
12 |
private $viafResolver; |
|
13 |
||
14 |
public function setUp() { |
|
15 |
||
16 |
parent::setup(); |
|
17 |
||
18 |
// create a mock of the post repository interface and inject it into the |
|
19 |
// IoC container |
|
20 |
$this->viafResolver = m::mock('CorpusParole\Services\ViafResolverInterface'); |
|
21 |
$this->app->instance('CorpusParole\Services\ViafResolverInterface', $this->viafResolver); |
|
22 |
} |
|
23 |
||
24 |
public function tearDown() { |
|
25 |
m::close(); |
|
26 |
parent::tearDown(); |
|
27 |
} |
|
28 |
||
29 |
public function testShow() { |
|
30 |
$this->viafResolver |
|
31 |
->shouldReceive('getNames') |
|
32 |
->with(['93752300', '56666014']) |
|
33 |
->once() |
|
34 |
->andReturn([ |
|
35 |
'56666014' => 'Guylaine Brun-Trigaud', |
|
36 |
'93752300' => 'Sonia Branca-Rosoff' |
|
37 |
]); |
|
306
3fccf43160a7
Some more changes linked to the change of api organization + some jshint error cleaning
ymh <ymh.work@gmail.com>
parents:
23
diff
changeset
|
38 |
$response = $this->get('/api/v1/resolvers/viaf/93752300,56666014')-> |
537
d2e6ee099125
upgrade ember + laravel + make everything work
ymh <ymh.work@gmail.com>
parents:
407
diff
changeset
|
39 |
assertJson(['viafids' => [ |
23 | 40 |
'56666014' => 'Guylaine Brun-Trigaud', |
41 |
'93752300' => 'Sonia Branca-Rosoff' |
|
42 |
]]); |
|
43 |
} |
|
44 |
||
45 |
public function testShowOne() { |
|
46 |
$this->viafResolver |
|
47 |
->shouldReceive('getNames') |
|
48 |
->with(['93752300']) |
|
49 |
->once() |
|
50 |
->andReturn([ |
|
51 |
'93752300' => 'Sonia Branca-Rosoff' |
|
52 |
]); |
|
306
3fccf43160a7
Some more changes linked to the change of api organization + some jshint error cleaning
ymh <ymh.work@gmail.com>
parents:
23
diff
changeset
|
53 |
$response = $this->get('/api/v1/resolvers/viaf/93752300')-> |
537
d2e6ee099125
upgrade ember + laravel + make everything work
ymh <ymh.work@gmail.com>
parents:
407
diff
changeset
|
54 |
assertJson(['viafids' => [ |
23 | 55 |
'93752300' => 'Sonia Branca-Rosoff' |
56 |
]]); |
|
57 |
} |
|
58 |
||
59 |
public function testShowUnknown() { |
|
60 |
$this->viafResolver |
|
61 |
->shouldReceive('getNames') |
|
62 |
->with(['12345']) |
|
63 |
->once() |
|
64 |
->andReturn([ |
|
65 |
'12345' => null |
|
66 |
]); |
|
306
3fccf43160a7
Some more changes linked to the change of api organization + some jshint error cleaning
ymh <ymh.work@gmail.com>
parents:
23
diff
changeset
|
67 |
$response = $this->get('/api/v1/resolvers/viaf/12345')-> |
537
d2e6ee099125
upgrade ember + laravel + make everything work
ymh <ymh.work@gmail.com>
parents:
407
diff
changeset
|
68 |
assertJson(['viafids' => [ |
23 | 69 |
'12345' => null |
70 |
]]); |
|
71 |
} |
|
72 |
||
73 |
public function testShowMalformed() { |
|
74 |
$this->viafResolver |
|
75 |
->shouldReceive('getNames') |
|
76 |
->with(['abcdef','ghij']) |
|
77 |
->once() |
|
407
2dba812c7ef2
add a way to build rpm for puppet files, correct elasticsearch provisioning, correct error on elasticsearch queries + tests
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
78 |
->andThrow('CorpusParole\Services\ViafResolverException', "ViafId not in correct format", 500); |
306
3fccf43160a7
Some more changes linked to the change of api organization + some jshint error cleaning
ymh <ymh.work@gmail.com>
parents:
23
diff
changeset
|
79 |
$response = $this->get('/api/v1/resolvers/viaf/abcdef,ghij'); |
23 | 80 |
|
537
d2e6ee099125
upgrade ember + laravel + make everything work
ymh <ymh.work@gmail.com>
parents:
407
diff
changeset
|
81 |
$response->assertStatus(500); |
23 | 82 |
} |
83 |
||
84 |
} |