Skip to content

Commit

Permalink
chore: 🤖 Improve CI (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpyw authored Jun 24, 2021
1 parent cb4273f commit 1238222
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 34 deletions.
44 changes: 27 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
language: php

matrix:
include:
- php: 5.6
env: PHPUNIT_VERSION=5.7.* COMPOSER_FLAGS="--prefer-stable"
- php: 5.6
env: PHPUNIT_VERSION=5.7.* COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
- php: 7.0
env: COMPOSER_FLAGS="--prefer-stable"
- php: 7.0
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
- php: 7.4
env: COMPOSER_FLAGS="--prefer-stable"
- php: 7.4
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4
- 8.0

env:
- COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
- COMPOSER_FLAGS="--prefer-stable"

cache:
directories:
Expand All @@ -22,10 +20,22 @@ cache:

before_script:
- composer self-update
- if [ "$PHPUNIT_VERSION" != "" ]; then composer require "phpunit/phpunit:${PHPUNIT_VERSION}" --dev --no-update; fi;
- composer require phpunit/phpunit --dev --no-update
- composer remove friendsofphp/php-cs-fixer --dev --no-update
- composer require doctrine/orm:^2.4 $COMPOSER_FLAGS --no-update
- composer update
- |
if php -r 'exit((int)!version_compare(PHP_VERSION, "7.4", ">="));'; then
composer require doctrine/orm:^2.6.4 $COMPOSER_FLAGS --no-update
elif php -r 'exit((int)!version_compare(PHP_VERSION, "7.3", ">="));'; then
composer require doctrine/orm:^2.6.3 $COMPOSER_FLAGS --no-update
else
composer require doctrine/orm:^2.4.5 $COMPOSER_FLAGS --no-update
fi
- |
if php -r 'exit((int)!version_compare(PHP_VERSION, "7.1", "<"));'; then
composer remove doctrine/cache --dev --no-update
fi
- composer update $COMPOSER_FLAGS
- composer show | grep -E '^(doctrine/|lampager/)'
- mkdir -p build/logs

script:
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@ Rapid pagination for Doctrine 2

## Requirements

- PHP: ^5.6 || ^7.0 || ^8.0
- [doctrine/orm](https://github.com/doctrine/orm): ^2.4
- [lampager/lampager](https://github.com/lampager/lampager): ^0.4
- PHP: `>=5.6`
- [doctrine/orm](https://github.com/doctrine/orm): `^2.4.5`
- [lampager/lampager](https://github.com/lampager/lampager): `^0.4`

### Matrix

| PHP | [doctrine/orm](https://github.com/doctrine/orm) | [lampager/lampager](https://github.com/lampager/lampager) |
|:---|:---|:---|
| `>=7.4` | `^2.6.4` | `^0.4` |
| `>=7.3` `<7.4` | `^2.6.3` | `^0.4` |
| `>=5.6` `<7.3` | `^2.4.5` | `^0.4` |

## Installing

Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
"php": "^5.6 || ^7.0 || ^8.0",
"ext-json": "*",
"lampager/lampager": "^0.4",
"doctrine/orm": "^2.4"
"doctrine/orm": "^2.4.5"
},
"require-dev": {
"phpunit/phpunit": "^6.4",
"php-coveralls/php-coveralls": "^1.0",
"nilportugues/sql-query-formatter": "^1.2",
"friendsofphp/php-cs-fixer": "^3.0"
"nilportugues/sql-query-formatter": "^1.2.2",
"friendsofphp/php-cs-fixer": "^3.0",
"doctrine/cache": "^1.11"
}
}
1 change: 0 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Package Test Suite">
Expand Down
14 changes: 8 additions & 6 deletions tests/ProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@

class ProcessorTest extends TestCase
{
protected function setUp()
/**
* @before
*/
protected function setUpFormatter()
{
parent::setUp();

Processor::setDefaultFormatter(function ($rows, array $meta) {
foreach (['previous', 'next'] as $type) {
if (isset($meta["{$type}Cursor"])) {
Expand All @@ -27,10 +28,11 @@ protected function setUp()
});
}

protected function tearDown()
/**
* @after
*/
protected function removeFormatter()
{
parent::tearDown();

Processor::restoreDefaultFormatter();
}

Expand Down
7 changes: 3 additions & 4 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ abstract class TestCase extends BasesTestCase
];

/**
* @before
* @throws \Doctrine\ORM\ORMException
* @throws \Exception
*/
protected function setUp()
protected function setUpDatabase()
{
parent::setUp();

$config = Setup::createAnnotationMetadataConfiguration(
[__DIR__ . '/Entities'],
false,
Expand All @@ -63,7 +62,7 @@ protected function setUp()
foreach (static::$data['posts'] as $row) {
$post = new Post();
$post->setId($row['id']);
$post->setUpdatedAt(new \DateTimeImmutable($row['updatedAt']));
$post->setUpdatedAt(new \DateTime($row['updatedAt']));
$this->entities->persist($post);
}

Expand Down

0 comments on commit 1238222

Please sign in to comment.