diff --git a/.travis.yml b/.travis.yml index 712c45c..49d023f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,12 +7,6 @@ cache: matrix: include: - - php: 5.3 - dist: precise - - php: 5.4 - dist: precise - - php: 5.5 - dist: precise - php: 5.6 - php: 7.0 - php: 7.1 diff --git a/ActivityRepositoryInterface.php b/ActivityRepositoryInterface.php new file mode 100644 index 0000000..4d23d57 --- /dev/null +++ b/ActivityRepositoryInterface.php @@ -0,0 +1,26 @@ + + */ +interface ActivityRepositoryInterface +{ + /** + * Finds an {@link Activity} by id. + * + * @param IRI $activityId The activity id to filter by + * + * @return Activity The activity + * + * @throws NotFoundException if no Activity with the given IRI does exist + */ + public function findActivityById(IRI $activityId); +} diff --git a/CHANGELOG.md b/CHANGELOG.md index b23c1f5..dce26dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ CHANGELOG ========= +0.4.0 +----- + +* dropped suppport for PHP < 5.6 and HHVM + +* made the package compatible with `3.x` releases of `ramsey/uuid` + +* allow `2.x` and `3.x` releases of the `php-xapi/model` package too + +* added an `ActivityRepositoryInterface` that defines the public API of + an activity repository + 0.3.1 ----- diff --git a/Test/Functional/ActivityRepositoryTest.php b/Test/Functional/ActivityRepositoryTest.php new file mode 100644 index 0000000..29cdaac --- /dev/null +++ b/Test/Functional/ActivityRepositoryTest.php @@ -0,0 +1,76 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace XApi\Repository\Api\Test\Functional; + +use PHPUnit\Framework\TestCase; +use Xabbuh\XApi\Model\Activity; +use Xabbuh\XApi\Model\IRI; +use XApi\Repository\Api\ActivityRepositoryInterface; + +/** + * @author Jérôme Parmentier + */ +abstract class ActivityRepositoryTest extends TestCase +{ + /** + * @var ActivityRepositoryInterface + */ + private $activityRepository; + + protected function setUp() + { + $this->activityRepository = $this->createActivityRepository(); + $this->cleanDatabase(); + } + + protected function tearDown() + { + $this->cleanDatabase(); + } + + /** + * @expectedException \Xabbuh\XApi\Common\Exception\NotFoundException + */ + public function testFetchingNonExistingActivityThrowsException() + { + $this->activityRepository->findActivityById(IRI::fromString('not-existing')); + } + + /** + * @dataProvider getStatementsWithId + */ + public function testActivitiesCanBeRetrievedById(Activity $activity) + { + $fetchedActivity = $this->activityRepository->findActivityById($activity->getId()); + + $this->assertTrue($activity->equals($fetchedActivity)); + } + + public function getActivitiesWithId() + { + $fixtures = array(); + + foreach (get_class_methods('Xabbuh\XApi\DataFixtures\ActivityFixtures') as $method) { + $activity = call_user_func(array('Xabbuh\XApi\DataFixtures\ActivityFixtures', $method)); + + if ($activity instanceof Activity) { + $fixtures[$method] = array($activity); + } + } + + return $fixtures; + } + + abstract protected function createActivityRepository(); + + abstract protected function cleanDatabase(); +} diff --git a/composer.json b/composer.json index 99457f9..60c0f62 100644 --- a/composer.json +++ b/composer.json @@ -11,10 +11,12 @@ } ], "require": { + "php": "^5.6 || ^7.0", "ramsey/uuid": "^2.8 || ^3.0", - "php-xapi/model": "^1.0", + "php-xapi/model": "^1.1 || ^2.0 || ^3.0", "php-xapi/test-fixtures": "^1.0" }, + "minimum-stability": "dev", "conflict": { "xabbuh/xapi-storage-api": "*" }, @@ -25,7 +27,7 @@ }, "extra": { "branch-alias": { - "dev-master": "0.3.x-dev" + "dev-master": "0.4.x-dev" } } }