server/src/tests/Controllers/ViafControllerTest.php
changeset 306 3fccf43160a7
parent 23 037687868bc4
child 407 2dba812c7ef2
equal deleted inserted replaced
305:ff6cf3fc5f40 306:3fccf43160a7
    33             ->once()
    33             ->once()
    34             ->andReturn([
    34             ->andReturn([
    35                 '56666014' => 'Guylaine Brun-Trigaud',
    35                 '56666014' => 'Guylaine Brun-Trigaud',
    36                 '93752300' => 'Sonia Branca-Rosoff'
    36                 '93752300' => 'Sonia Branca-Rosoff'
    37             ]);
    37             ]);
    38         $response = $this->get('/api/v1/viaf/93752300,56666014')->
    38         $response = $this->get('/api/v1/resolvers/viaf/93752300,56666014')->
    39             seeJsonEquals(['viafids' => [
    39             seeJsonEquals(['viafids' => [
    40                 '56666014' => 'Guylaine Brun-Trigaud',
    40                 '56666014' => 'Guylaine Brun-Trigaud',
    41                 '93752300' => 'Sonia Branca-Rosoff'
    41                 '93752300' => 'Sonia Branca-Rosoff'
    42             ]]);
    42             ]]);
    43     }
    43     }
    48             ->with(['93752300'])
    48             ->with(['93752300'])
    49             ->once()
    49             ->once()
    50             ->andReturn([
    50             ->andReturn([
    51                 '93752300' => 'Sonia Branca-Rosoff'
    51                 '93752300' => 'Sonia Branca-Rosoff'
    52             ]);
    52             ]);
    53         $response = $this->get('/api/v1/viaf/93752300')->
    53         $response = $this->get('/api/v1/resolvers/viaf/93752300')->
    54             seeJsonEquals(['viafids' => [
    54             seeJsonEquals(['viafids' => [
    55                 '93752300' => 'Sonia Branca-Rosoff'
    55                 '93752300' => 'Sonia Branca-Rosoff'
    56             ]]);
    56             ]]);
    57     }
    57     }
    58 
    58 
    62             ->with(['12345'])
    62             ->with(['12345'])
    63             ->once()
    63             ->once()
    64             ->andReturn([
    64             ->andReturn([
    65                 '12345' => null
    65                 '12345' => null
    66             ]);
    66             ]);
    67         $response = $this->get('/api/v1/viaf/12345')->
    67         $response = $this->get('/api/v1/resolvers/viaf/12345')->
    68             seeJsonEquals(['viafids' => [
    68             seeJsonEquals(['viafids' => [
    69                 '12345' => null
    69                 '12345' => null
    70             ]]);
    70             ]]);
    71     }
    71     }
    72 
    72 
    74         $this->viafResolver
    74         $this->viafResolver
    75             ->shouldReceive('getNames')
    75             ->shouldReceive('getNames')
    76             ->with(['abcdef','ghij'])
    76             ->with(['abcdef','ghij'])
    77             ->once()
    77             ->once()
    78             ->andThrow('CorpusParole\Services\ViafResolverException', "ViafId not in correct format", 400);
    78             ->andThrow('CorpusParole\Services\ViafResolverException', "ViafId not in correct format", 400);
    79         $response = $this->get('/api/v1/viaf/abcdef,ghij');
    79         $response = $this->get('/api/v1/resolvers/viaf/abcdef,ghij');
    80 
    80 
    81         $this->assertResponseStatus(400);
    81         $this->assertResponseStatus(400);
    82     }
    82     }
    83 
    83 
    84 }
    84 }