Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test a theory. #50

Merged
merged 11 commits into from
Jul 21, 2016
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ![Chullo](https://cloud.githubusercontent.com/assets/2371345/15409650/21fd66a6-1dec-11e6-9fb3-4a1554a0fb3d.png) Chullo

Chullo is a PHP client for Fedora 4 built using Guzzle and EasyRdf.
Chullo is a PHP client for [Fedora 4](http://fedorarepository.org/) built using [Guzzle](http://guzzlephp.org) and [EasyRdf](http://www.easyrdf.org/).

[![Latest Stable Version](https://img.shields.io/packagist/v/Islandora/chullo.svg?style=flat-square)](https://packagist.org/packages/islandora/chullo)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%205.5-8892BF.svg?style=flat-square)](https://php.net/)
Expand Down
7 changes: 4 additions & 3 deletions src/Chullo.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* @package Islandora
* @author Daniel Lamb <[email protected]>
* @author Nick Ruest <[email protected]>
* @author Diego Pino <[email protected]>
* @license http://www.gnu.org/licenses/gpl-3.0.en.html GPL
* @link http://www.islandora.ca
*/
Expand Down Expand Up @@ -293,7 +294,7 @@ public function deleteResource(
* Issues a COPY request to Fedora.
*
* @param string $uri Resource URI
* @param array $destination Destination URI
* @param string $destination Destination URI
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change should be continued to FedoraApi's copyResource

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@whikloj pushed a new commit.

* @param string $transaction Transaction id
*
* @return string Uri of newly created copy or null if failed
Expand Down Expand Up @@ -322,7 +323,7 @@ public function copyResource(
* Issues a MOVE request to Fedora.
*
* @param string $uri Resource URI
* @param array $destination Destination URI
* @param string $destination Destination URI
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this change should probably be continued to FedoraApi's moveResource. We probably also need to look at prepareUri, it also seems to be a string but the doc comment says array (again both in Chullo and FedoraApi)

* @param string $transaction Transaction id
*
* @return string Uri of moved resource or null if failed
Expand Down Expand Up @@ -350,7 +351,7 @@ public function moveResource(
/**
* Creates a new transaction.
*
* @return string Transaction id or null if failure
* @return null|string Transaction id or null if failure
*/
public function createTransaction()
{
Expand Down
5 changes: 5 additions & 0 deletions src/FedoraApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
* @package Islandora
* @author Daniel Lamb <[email protected]>
* @author Nick Ruest <[email protected]>
* @author Jared Whiklo <[email protected]>
* @author Diego Pino <[email protected]>
* @license http://www.gnu.org/licenses/gpl-3.0.en.html GPL
* @link http://www.islandora.ca
*/
Expand All @@ -28,6 +30,9 @@
* @category Islandora
* @package Islandora
* @author Daniel Lamb <[email protected]>
* @author Nick Ruest <[email protected]>
* @author Jared Whiklo <[email protected]>
* @author Diego Pino <[email protected]>
* @license http://www.gnu.org/licenses/gpl-3.0.en.html GPL
* @link http://www.islandora.ca
*/
Expand Down
1 change: 1 addition & 0 deletions src/IFedoraApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* @category Islandora
* @package Islandora
* @author Daniel Lamb <[email protected]>
* @author Diego Pino <[email protected]>
* @license http://www.gnu.org/licenses/gpl-3.0.en.html GPL
* @link http://www.islandora.ca
*/
Expand Down
2 changes: 2 additions & 0 deletions src/IFedoraClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
* @category Islandora
* @package Islandora
* @author Daniel Lamb <[email protected]>
* @author Nick Ruest <[email protected]>
* @author Diego Pino <[email protected]>
* @license http://www.gnu.org/licenses/gpl-3.0.en.html GPL
* @link http://www.islandora.ca
*/
Expand Down
2 changes: 2 additions & 0 deletions src/ITriplestoreClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* @category Islandora
* @package Islandora
* @author Daniel Lamb <[email protected]>
* @author Nick Ruest <[email protected]>
* @license http://www.gnu.org/licenses/gpl-3.0.en.html GPL
* @link http://www.islandora.ca
*/
Expand All @@ -23,6 +24,7 @@
* @category Islandora
* @package Islandora
* @author Daniel Lamb <[email protected]>
* @author Diego Pino <[email protected]>
* @license http://www.gnu.org/licenses/gpl-3.0.en.html GPL
* @link http://www.islandora.ca
*/
Expand Down
2 changes: 2 additions & 0 deletions src/TriplestoreClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
* @category Islandora
* @package Islandora
* @author Daniel Lamb <[email protected]>
* @author Nick Ruest <[email protected]>
* @author Diego Pino <[email protected]>
* @license http://www.gnu.org/licenses/gpl-3.0.en.html GPL
* @link http://www.islandora.ca
*/
Expand Down
6 changes: 4 additions & 2 deletions test/CommitTransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class CommitTransactionTest extends \PHPUnit_Framework_TestCase

/**
* @covers Islandora\Chullo\Chullo::commitTransaction
* @covers Islandora\Chullo\FedoraApi::commitTransaction
* @uses GuzzleHttp\Client
*/
public function testReturnsTrue204()
Expand All @@ -32,8 +33,9 @@ public function testReturnsTrue204()
}

/**
* @covers Islandora\Chullo\Chullo::commitTransaction
* @uses GuzzleHttp\Client
* @covers Islandora\Chullo\Chullo::commitTransaction
* @covers Islandora\Chullo\FedoraApi::commitTransaction
* @uses GuzzleHttp\Client
*/
public function testReturnsFalseOtherwise()
{
Expand Down
6 changes: 4 additions & 2 deletions test/CopyResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class CopyResourceTest extends \PHPUnit_Framework_TestCase

/**
* @covers Islandora\Chullo\Chullo::copyResource
* @covers Islandora\Chullo\FedoraApi::copyResource
* @uses GuzzleHttp\Client
*/
public function testReturnsUriOn201()
Expand All @@ -32,8 +33,9 @@ public function testReturnsUriOn201()
}

/**
* @covers Islandora\Chullo\Chullo::copyResource
* @uses GuzzleHttp\Client
* @covers Islandora\Chullo\Chullo::copyResource
* @covers Islandora\Chullo\FedoraApi::copyResource
* @uses GuzzleHttp\Client
*/
public function testReturnsNullOtherwise()
{
Expand Down
6 changes: 4 additions & 2 deletions test/CreateResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class CreateResourceTest extends \PHPUnit_Framework_TestCase

/**
* @covers Islandora\Chullo\Chullo::createResource
* @covers Islandora\Chullo\FedoraApi::createResource
* @uses GuzzleHttp\Client
*/
public function testReturnsUriOn201()
Expand All @@ -32,8 +33,9 @@ public function testReturnsUriOn201()
}

/**
* @covers Islandora\Chullo\Chullo::createResource
* @uses GuzzleHttp\Client
* @covers Islandora\Chullo\Chullo::createResource
* @covers Islandora\Chullo\FedoraApi::createResource
* @uses GuzzleHttp\Client
*/
public function testReturnsNullOtherwise()
{
Expand Down
20 changes: 16 additions & 4 deletions test/CreateTransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class CreateTransactionTest extends \PHPUnit_Framework_TestCase

/**
* @covers Islandora\Chullo\Chullo::createTransaction
* @covers Islandora\Chullo\FedoraApi::createTransaction
* @uses GuzzleHttp\Client
*/
public function testReturnsIdOn201()
Expand All @@ -32,11 +33,22 @@ public function testReturnsIdOn201()
}
/**
* @covers Islandora\Chullo\Chullo::createTransaction
* @covers Islandora\Chullo\FedoraApi::createTransaction
* @uses GuzzleHttp\Client
*/
public function testReturnsEmpty()
public function testReturnsNullOtherwise()
{
$uri = null;
$this->assertEmpty($uri);
$this->assertNull($uri);
$mock = new MockHandler([
new Response(404),
]);

$handler = HandlerStack::create($mock);
$guzzle = new Client(['handler' => $handler]);
$api = new FedoraApi($guzzle);
$client = new Chullo($api);

//404
$result = $client->createResource();
$this->assertNull($result);
}
}
6 changes: 4 additions & 2 deletions test/DeleteResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class DeleteResourceTest extends \PHPUnit_Framework_TestCase

/**
* @covers Islandora\Chullo\Chullo::deleteResource
* @covers Islandora\Chullo\FedoraApi::deleteResource
* @uses GuzzleHttp\Client
*/
public function testReturnsTrueOn204()
Expand All @@ -32,8 +33,9 @@ public function testReturnsTrueOn204()
}

/**
* @covers Islandora\Chullo\Chullo::deleteResource
* @uses GuzzleHttp\Client
* @covers Islandora\Chullo\Chullo::deleteResource
* @covers Islandora\Chullo\FedoraApi::deleteResource
* @uses GuzzleHttp\Client
*/
public function testReturnsFalseOtherwise()
{
Expand Down
6 changes: 4 additions & 2 deletions test/ExtendTransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ExtendTransactionTest extends \PHPUnit_Framework_TestCase

/**
* @covers Islandora\Chullo\Chullo::extendTransaction
* @covers Islandora\Chullo\FedoraApi::extendTransaction
* @uses GuzzleHttp\Client
*/
public function testReturnsTrueOn204()
Expand All @@ -32,8 +33,9 @@ public function testReturnsTrueOn204()
}

/**
* @covers Islandora\Chullo\Chullo::extendTransaction
* @uses GuzzleHttp\Client
* @covers Islandora\Chullo\Chullo::extendTransaction
* @covers Islandora\Chullo\FedoraApi::extendTransaction
* @uses GuzzleHttp\Client
*/
public function testReturnsFalseOtherwise()
{
Expand Down
2 changes: 2 additions & 0 deletions test/GetResourceHeadersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class GetResourceHeadersTest extends \PHPUnit_Framework_TestCase

/**
* @covers Islandora\Chullo\Chullo::getResourceHeaders
* @covers Islandora\Chullo\FedoraApi::getResourceHeaders
* @uses GuzzleHttp\Client
*/
public function testReturnsHeadersOn200()
Expand Down Expand Up @@ -46,6 +47,7 @@ public function testReturnsHeadersOn200()

/**
* @covers Islandora\Chullo\Chullo::getResourceHeaders
* @covers Islandora\Chullo\FedoraApi::getResourceHeaders
* @uses GuzzleHttp\Client
*/
public function testReturnsNullOtherwise()
Expand Down
1 change: 1 addition & 0 deletions test/GetResourceOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class GetResourceOptionsTest extends \PHPUnit_Framework_TestCase

/**
* @covers Islandora\Chullo\Chullo::getResourceOptions
* @covers Islandora\Chullo\FedoraApi::getResourceOptions
* @uses GuzzleHttp\Client
*/
public function testReturnsHeadersOn200()
Expand Down
6 changes: 4 additions & 2 deletions test/ModifyResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ModifyResourceTest extends \PHPUnit_Framework_TestCase

/**
* @covers Islandora\Chullo\Chullo::modifyResource
* @covers Islandora\Chullo\FedoraApi::modifyResource
* @uses GuzzleHttp\Client
*/
public function testReturnsTrueOn204()
Expand All @@ -32,8 +33,9 @@ public function testReturnsTrueOn204()
}

/**
* @covers Islandora\Chullo\Chullo::modifyResource
* @uses GuzzleHttp\Client
* @covers Islandora\Chullo\Chullo::modifyResource
* @covers Islandora\Chullo\FedoraApi::modifyResource
* @uses GuzzleHttp\Client
*/
public function testReturnsFalseOtherwise()
{
Expand Down
6 changes: 4 additions & 2 deletions test/MoveResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class MoveResourceTest extends \PHPUnit_Framework_TestCase

/**
* @covers Islandora\Chullo\Chullo::moveResource
* @covers Islandora\Chullo\FedoraApi::moveResource
* @uses GuzzleHttp\Client
*/
public function testReturnsUriOn201()
Expand All @@ -32,8 +33,9 @@ public function testReturnsUriOn201()
}

/**
* @covers Islandora\Chullo\Chullo::moveResource
* @uses GuzzleHttp\Client
* @covers Islandora\Chullo\Chullo::moveResource
* @covers Islandora\Chullo\FedoraApi::moveResource
* @uses GuzzleHttp\Client
*/
public function testReturnsNullOtherwise()
{
Expand Down
6 changes: 4 additions & 2 deletions test/RollbackTransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class RollbackTransactionTest extends \PHPUnit_Framework_TestCase

/**
* @covers Islandora\Chullo\Chullo::rollbackTransaction
* @covers Islandora\Chullo\FedoraApi::rollbackTransaction
* @uses GuzzleHttp\Client
*/
public function testReturnsTrueOn204()
Expand All @@ -32,8 +33,9 @@ public function testReturnsTrueOn204()
}

/**
* @covers Islandora\Chullo\Chullo::rollbackTransaction
* @uses GuzzleHttp\Client
* @covers Islandora\Chullo\Chullo::rollbackTransaction
* @covers Islandora\Chullo\FedoraApi::rollbackTransaction
* @uses GuzzleHttp\Client
*/
public function testReturnsFalseOtherwise()
{
Expand Down
6 changes: 4 additions & 2 deletions test/SaveResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class SaveResourceTest extends \PHPUnit_Framework_TestCase

/**
* @covers Islandora\Chullo\Chullo::saveResource
* @covers Islandora\Chullo\FedoraApi::saveResource
* @uses GuzzleHttp\Client
*/
public function testReturnsTrueOn204()
Expand All @@ -32,8 +33,9 @@ public function testReturnsTrueOn204()
}

/**
* @covers Islandora\Chullo\Chullo::saveResource
* @uses GuzzleHttp\Client
* @covers Islandora\Chullo\Chullo::saveResource
* @covers Islandora\Chullo\FedoraApi::saveResource
* @uses GuzzleHttp\Client
*/
public function testReturnsFalseOtherwise()
{
Expand Down