server/src/tests/Controllers/GeonamesControllerTest.php
changeset 306 3fccf43160a7
parent 304 20071981ba2a
child 407 2dba812c7ef2
equal deleted inserted replaced
305:ff6cf3fc5f40 306:3fccf43160a7
    31             ->shouldReceive('getLabels')
    31             ->shouldReceive('getLabels')
    32             ->with(['2968801', '2988507', '6255148'])
    32             ->with(['2968801', '2988507', '6255148'])
    33             ->once()
    33             ->once()
    34             ->andReturn(['2968801' => 'Villedieu-les-Poêles', '2988507' => 'Paris', '6255148' => 'Europe']);
    34             ->andReturn(['2968801' => 'Villedieu-les-Poêles', '2988507' => 'Paris', '6255148' => 'Europe']);
    35 
    35 
    36         $response = $this->get('/api/v1/geonames/2968801,2988507,6255148')->
    36         $response = $this->get('/api/v1/resolvers/geonames/2968801,2988507,6255148')->
    37             seeJsonEquals(['geonamesids' => ['2968801' => 'Villedieu-les-Poêles', '2988507' => 'Paris', '6255148' => 'Europe']]);
    37             seeJsonEquals(['geonamesids' => ['2968801' => 'Villedieu-les-Poêles', '2988507' => 'Paris', '6255148' => 'Europe']]);
    38     }
    38     }
    39 
    39 
    40     public function testShowOne() {
    40     public function testShowOne() {
    41         $this->geonamesResolver
    41         $this->geonamesResolver
    43             ->with(['2968801'])
    43             ->with(['2968801'])
    44             ->once()
    44             ->once()
    45             ->andReturn([
    45             ->andReturn([
    46                 '2968801' => 'Villedieu-les-Poêles'
    46                 '2968801' => 'Villedieu-les-Poêles'
    47             ]);
    47             ]);
    48         $response = $this->get('/api/v1/geonames/2968801')->
    48         $response = $this->get('/api/v1/resolvers/geonames/2968801')->
    49             seeJsonEquals(['geonamesids' => [
    49             seeJsonEquals(['geonamesids' => [
    50                 '2968801' => 'Villedieu-les-Poêles'
    50                 '2968801' => 'Villedieu-les-Poêles'
    51             ]]);
    51             ]]);
    52     }
    52     }
    53 
    53 
    57             ->with(['12345'])
    57             ->with(['12345'])
    58             ->once()
    58             ->once()
    59             ->andReturn([
    59             ->andReturn([
    60                 '12345' => null
    60                 '12345' => null
    61             ]);
    61             ]);
    62         $response = $this->get('/api/v1/geonames/12345')->
    62         $response = $this->get('/api/v1/resolvers/geonames/12345')->
    63             seeJsonEquals(['geonamesids' => [
    63             seeJsonEquals(['geonamesids' => [
    64                 '12345' => null
    64                 '12345' => null
    65             ]]);
    65             ]]);
    66     }
    66     }
    67 
    67 
    69         $this->geonamesResolver
    69         $this->geonamesResolver
    70             ->shouldReceive('getLabels')
    70             ->shouldReceive('getLabels')
    71             ->with(['abcdef','ghij'])
    71             ->with(['abcdef','ghij'])
    72             ->once()
    72             ->once()
    73             ->andThrow('CorpusParole\Services\GeonamesResolverException', "GeonamesId not in correct format", 400);
    73             ->andThrow('CorpusParole\Services\GeonamesResolverException', "GeonamesId not in correct format", 400);
    74         $response = $this->get('/api/v1/geonames/abcdef,ghij');
    74         $response = $this->get('/api/v1/resolvers/geonames/abcdef,ghij');
    75 
    75 
    76         $this->assertResponseStatus(400);
    76         $this->assertResponseStatus(400);
    77     }
    77     }
    78 
    78 
    79 }
    79 }