server/src/tests/Controllers/BnfControllerTest.php
changeset 306 3fccf43160a7
parent 133 821253d361d1
child 537 d2e6ee099125
equal deleted inserted replaced
305:ff6cf3fc5f40 306:3fccf43160a7
    37             ->once()
    37             ->once()
    38             ->andReturn([
    38             ->andReturn([
    39                 'ark:/12148/cb11946662b' => 'parents et enfants',
    39                 'ark:/12148/cb11946662b' => 'parents et enfants',
    40                 'ark:/12148/cb11965628b' => 'frères et soeurs'
    40                 'ark:/12148/cb11965628b' => 'frères et soeurs'
    41             ]);
    41             ]);
    42         $response = $this->get('/api/v1/bnf/cb11946662b,cb11965628b')->
    42         $response = $this->get('/api/v1/resolvers/bnf/cb11946662b,cb11965628b')->
    43             seeJsonEquals(['bnfids' => [
    43             seeJsonEquals(['bnfids' => [
    44                 'ark:/12148/cb11946662b' => 'parents et enfants',
    44                 'ark:/12148/cb11946662b' => 'parents et enfants',
    45                 'ark:/12148/cb11965628b' => 'frères et soeurs'
    45                 'ark:/12148/cb11965628b' => 'frères et soeurs'
    46             ]]);
    46             ]]);
    47     }
    47     }
    52             ->with(['ark:/12148/cb11946662b'])
    52             ->with(['ark:/12148/cb11946662b'])
    53             ->once()
    53             ->once()
    54             ->andReturn([
    54             ->andReturn([
    55                 'ark:/12148/cb11946662b' => 'parents et enfants'
    55                 'ark:/12148/cb11946662b' => 'parents et enfants'
    56             ]);
    56             ]);
    57         $response = $this->get('/api/v1/bnf/cb11946662b')->
    57         $response = $this->get('/api/v1/resolvers/bnf/cb11946662b')->
    58             seeJsonEquals(['bnfids' => [
    58             seeJsonEquals(['bnfids' => [
    59                 'ark:/12148/cb11946662b' => 'parents et enfants'
    59                 'ark:/12148/cb11946662b' => 'parents et enfants'
    60             ]]);
    60             ]]);
    61     }
    61     }
    62 
    62 
    66             ->with(['ark:/12148/cb12345678b'])
    66             ->with(['ark:/12148/cb12345678b'])
    67             ->once()
    67             ->once()
    68             ->andReturn([
    68             ->andReturn([
    69                 'ark:/12148/cb12345678b' => null
    69                 'ark:/12148/cb12345678b' => null
    70             ]);
    70             ]);
    71         $response = $this->get('/api/v1/bnf/cb12345678b')->
    71         $response = $this->get('/api/v1/resolvers/bnf/cb12345678b')->
    72             seeJsonEquals(['bnfids' => [
    72             seeJsonEquals(['bnfids' => [
    73                 'ark:/12148/cb12345678b' => null
    73                 'ark:/12148/cb12345678b' => null
    74             ]]);
    74             ]]);
    75     }
    75     }
    76 
    76 
    78         $this->bnfResolver
    78         $this->bnfResolver
    79             ->shouldReceive('getLabels')
    79             ->shouldReceive('getLabels')
    80             ->with(['ark:/12148/abcdef','ark:/12148/ghij'])
    80             ->with(['ark:/12148/abcdef','ark:/12148/ghij'])
    81             ->once()
    81             ->once()
    82             ->andThrow('CorpusParole\Services\BnfResolverException', "BnfId not in correct format", 500);
    82             ->andThrow('CorpusParole\Services\BnfResolverException', "BnfId not in correct format", 500);
    83         $response = $this->get('/api/v1/bnf/abcdef,ghij');
    83         $response = $this->get('/api/v1/resolvers/bnf/abcdef,ghij');
    84 
    84 
    85         $this->assertResponseStatus(500);
    85         $this->assertResponseStatus(500);
    86     }
    86     }
    87 
    87 
    88 }
    88 }