-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Recast service Move Milliner to use GeminiClient in Crayfish-Commons * Update crayfish-commons so we can use GeminiClient * Fix tests * Fix the composers * Make Milliner installable by PHP 7.0 * Test for invalid operation * Point at crayfish-commons master
- Loading branch information
Showing
28 changed files
with
5,627 additions
and
629 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ coverage.xml | |
*.key | ||
*.log | ||
syn-settings.xml | ||
cfg/config.yaml | ||
*/cfg/config.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
<?php | ||
|
||
namespace Islandora\Gemini\Tests; | ||
|
||
use Islandora\Gemini\Controller\GeminiController; | ||
use Islandora\Gemini\UrlMapper\UrlMapperInterface; | ||
use Islandora\Gemini\UrlMinter\UrlMinterInterface; | ||
use PHPUnit\Framework\TestCase; | ||
use Prophecy\Argument; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\Routing\Generator\UrlGenerator; | ||
|
||
/** | ||
* Class GetByUriTest | ||
* | ||
* @package Islandora\Gemini\Tests | ||
* @coversDefaultClass \Islandora\Gemini\Controller\GeminiController | ||
*/ | ||
class GetByUriTest extends TestCase | ||
{ | ||
|
||
/** | ||
* @covers ::getByUri | ||
*/ | ||
public function testGetByUriOk() | ||
{ | ||
$mapper = $this->prophesize(UrlMapperInterface::class); | ||
$mapper->findUrls(Argument::any()) | ||
->willReturn(['uri' => 'abc']); | ||
$mapper = $mapper->reveal(); | ||
|
||
$minter = $this->prophesize(UrlMinterInterface::class)->reveal(); | ||
|
||
$generator = $this->prophesize(UrlGenerator::class)->reveal(); | ||
|
||
$request = new Request(); | ||
$request->headers->add(['X-Islandora-URI' => 'blah']); | ||
|
||
$controller = new GeminiController( | ||
$mapper, | ||
$minter, | ||
$generator | ||
); | ||
|
||
$response = $controller->getByUri($request); | ||
|
||
$this->assertEquals( | ||
200, | ||
$response->getStatusCode(), | ||
"Response must be 200 on success" | ||
); | ||
$this->assertTrue( | ||
$response->headers->has('Location'), | ||
"Response must have Location header" | ||
); | ||
$this->assertEquals( | ||
'abc', | ||
$response->headers->get('Location'), | ||
"Location header should be 'abc'" | ||
); | ||
} | ||
|
||
/** | ||
* @covers ::getByUri | ||
*/ | ||
public function testGetByUriFailed() | ||
{ | ||
$mapper = $this->prophesize(UrlMapperInterface::class); | ||
$mapper->findUrls(Argument::any()) | ||
->willReturn([]); | ||
$mapper = $mapper->reveal(); | ||
|
||
$minter = $this->prophesize(UrlMinterInterface::class)->reveal(); | ||
|
||
$generator = $this->prophesize(UrlGenerator::class)->reveal(); | ||
|
||
$request = new Request(); | ||
$request->headers->add(['X-Islandora-URI' => 'blah']); | ||
|
||
$controller = new GeminiController( | ||
$mapper, | ||
$minter, | ||
$generator | ||
); | ||
|
||
$response = $controller->getByUri($request); | ||
|
||
$this->assertEquals( | ||
404, | ||
$response->getStatusCode(), | ||
"Response must be 200 on success" | ||
); | ||
} | ||
|
||
/** | ||
* @covers ::getByUri | ||
*/ | ||
public function testGetByUriMultiple() | ||
{ | ||
$mapper = $this->prophesize(UrlMapperInterface::class); | ||
$mapper->findUrls('foo') | ||
->willReturn(['uri' => 'abc']); | ||
$mapper->findUrls('bar') | ||
->willReturn(['uri' => 'oops']); | ||
$mapper = $mapper->reveal(); | ||
|
||
$minter = $this->prophesize(UrlMinterInterface::class)->reveal(); | ||
|
||
$generator = $this->prophesize(UrlGenerator::class)->reveal(); | ||
|
||
$request = new Request(); | ||
$request->headers->add(['X-Islandora-URI' => ['foo', 'bar']]); | ||
|
||
$controller = new GeminiController( | ||
$mapper, | ||
$minter, | ||
$generator | ||
); | ||
|
||
$response = $controller->getByUri($request); | ||
|
||
$this->assertEquals( | ||
200, | ||
$response->getStatusCode(), | ||
"Response must be 200 on success" | ||
); | ||
$this->assertTrue( | ||
$response->headers->has('Location'), | ||
"Response must have Location header" | ||
); | ||
$this->assertEquals( | ||
'abc', | ||
$response->headers->get('Location'), | ||
"Location header should be 'abc'" | ||
); | ||
} | ||
|
||
/** | ||
* @covers ::getByUri | ||
*/ | ||
public function testGetByUriNoToken() | ||
{ | ||
$mapper = $this->prophesize(UrlMapperInterface::class)->reveal(); | ||
$minter = $this->prophesize(UrlMinterInterface::class)->reveal(); | ||
$generator = $this->prophesize(UrlGenerator::class)->reveal(); | ||
|
||
$request = new Request(); | ||
|
||
$controller = new GeminiController( | ||
$mapper, | ||
$minter, | ||
$generator | ||
); | ||
|
||
$response = $controller->getByUri($request); | ||
|
||
$this->assertEquals( | ||
400, | ||
$response->getStatusCode(), | ||
"Response must be 400 with no X-Islandora-URI header" | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.