Add build test on PHP 8.0 & 8.1

Add `isTransactional` to `WallabagMigration` because PHP 8 behave differently with PDO transaction.
This is a workaround because we can't upgrade Doctrine Migration for now (upper versions have the fix).

- Build is now using Composer v2 (instead of v1)
- All actions have been updated to latest version
- Fix bug in PHP 8 were `$entry->getTags()` can't be properly used as a _traversable_ by `assertContains` during tests. Added a custom method `Entry::getTagsLabel()` which return a flatted tag array with only label
- Replace `assertNotRegExp` by `assertDoesNotMatchRegularExpression` because it was deprecated
This commit is contained in:
Jeremy Benoist 2022-01-31 09:27:20 +01:00
parent 6aeaaaabdd
commit 3c507d676f
No known key found for this signature in database
GPG key ID: BCA73962457ACC3C
15 changed files with 48 additions and 23 deletions

View file

@ -20,15 +20,15 @@ jobs:
uses: "shivammathur/setup-php@v2" uses: "shivammathur/setup-php@v2"
with: with:
coverage: "none" coverage: "none"
php-version: "7.3" php-version: "7.4"
tools: cs2pr, pecl, composer:v1 tools: cs2pr, pecl, composer:v2
extensions: pdo, pdo_mysql, pdo_sqlite, pdo_pgsql, curl, imagick, pgsql, gd, tidy extensions: pdo, pdo_mysql, pdo_sqlite, pdo_pgsql, curl, imagick, pgsql, gd, tidy
ini-values: "date.timezone=Europe/Paris" ini-values: "date.timezone=Europe/Paris"
env: env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Install dependencies with Composer" - name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1" uses: "ramsey/composer-install@v2"
with: with:
composer-options: "--optimize-autoloader --prefer-dist" composer-options: "--optimize-autoloader --prefer-dist"

View file

@ -32,6 +32,8 @@ jobs:
- "7.2" - "7.2"
- "7.3" - "7.3"
- "7.4" - "7.4"
- "8.0"
- "8.1"
database: database:
- "sqlite" - "sqlite"
- "mysql" - "mysql"
@ -48,7 +50,7 @@ jobs:
with: with:
php-version: "${{ matrix.php }}" php-version: "${{ matrix.php }}"
coverage: none coverage: none
tools: pecl, composer:v1 tools: pecl, composer:v2
extensions: json, pdo, pdo_mysql, pdo_sqlite, pdo_pgsql, curl, imagick, pgsql, gd, tidy extensions: json, pdo, pdo_mysql, pdo_sqlite, pdo_pgsql, curl, imagick, pgsql, gd, tidy
ini-values: "date.timezone=Europe/Paris" ini-values: "date.timezone=Europe/Paris"
@ -67,7 +69,7 @@ jobs:
pg_isready -d wallabag_test -h localhost -p 5432 -U wallabag pg_isready -d wallabag_test -h localhost -p 5432 -U wallabag
- name: "Install dependencies with Composer" - name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1" uses: "ramsey/composer-install@v2"
with: with:
composer-options: "--optimize-autoloader --prefer-dist" composer-options: "--optimize-autoloader --prefer-dist"

View file

@ -15,7 +15,7 @@ jobs:
strategy: strategy:
matrix: matrix:
php: php:
- "7.3" - "7.4"
steps: steps:
- name: "Checkout" - name: "Checkout"
@ -26,14 +26,14 @@ jobs:
with: with:
coverage: "none" coverage: "none"
php-version: "${{ matrix.php }}" php-version: "${{ matrix.php }}"
tools: pecl, composer:v1 tools: pecl, composer:v2
extensions: pdo, pdo_mysql, pdo_sqlite, pdo_pgsql, curl, imagick, pgsql, gd, tidy extensions: pdo, pdo_mysql, pdo_sqlite, pdo_pgsql, curl, imagick, pgsql, gd, tidy
ini-values: "date.timezone=Europe/Paris" ini-values: "date.timezone=Europe/Paris"
env: env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Install dependencies with Composer" - name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1" uses: "ramsey/composer-install@v2"
with: with:
composer-options: "--optimize-autoloader --prefer-dist" composer-options: "--optimize-autoloader --prefer-dist"

View file

@ -8,7 +8,7 @@
> >
<testsuites> <testsuites>
<testsuite name="wallabag Test Suite"> <testsuite name="wallabag">
<directory>tests</directory> <directory>tests</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>

View file

@ -30,6 +30,16 @@ abstract class WallabagMigration extends AbstractMigration implements ContainerA
$this->container = $container; $this->container = $container;
} }
/**
* @todo remove when upgrading DoctrineMigration (only needed for PHP 8)
*
* @see https://github.com/doctrine/DoctrineMigrationsBundle/issues/393
*/
public function isTransactional(): bool
{
return false;
}
protected function getTable($tableName, $unEscaped = false) protected function getTable($tableName, $unEscaped = false)
{ {
$table = $this->container->getParameter('database_table_prefix') . $tableName; $table = $this->container->getParameter('database_table_prefix') . $tableName;

View file

@ -682,6 +682,19 @@ class Entry
return $this->tags; return $this->tags;
} }
/**
* Only used during tests.
*/
public function getTagsLabel(): array
{
$tags = [];
foreach ($this->tags as $tag) {
$tags[] = $tag->getLabel();
}
return $tags;
}
/** /**
* @VirtualProperty * @VirtualProperty
* @SerializedName("tags") * @SerializedName("tags")

View file

@ -342,7 +342,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$entry = $em $entry = $em
->getRepository('WallabagCoreBundle:Entry') ->getRepository('WallabagCoreBundle:Entry')
->findOneByUrl($url); ->findOneByUrl($url);
$tags = $entry->getTags(); $tags = $entry->getTagsLabel();
$this->assertCount(2, $tags); $this->assertCount(2, $tags);
$this->assertContains('wallabag', $tags); $this->assertContains('wallabag', $tags);
@ -372,7 +372,7 @@ class EntryControllerTest extends WallabagCoreTestCase
->getRepository('WallabagCoreBundle:Entry') ->getRepository('WallabagCoreBundle:Entry')
->findOneByUrl($url); ->findOneByUrl($url);
$tags = $entry->getTags(); $tags = $entry->getTagsLabel();
$this->assertCount(2, $tags); $this->assertCount(2, $tags);
$this->assertContains('wallabag', $tags); $this->assertContains('wallabag', $tags);

View file

@ -46,7 +46,7 @@ class TagControllerTest extends WallabagCoreTestCase
// be sure to reload the entry // be sure to reload the entry
$entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId()); $entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId());
$this->assertCount(1, $entry->getTags()); $this->assertCount(1, $entry->getTags());
$this->assertContains($this->tagName, $entry->getTags()); $this->assertContains($this->tagName, $entry->getTagsLabel());
// tag already exists and already assigned // tag already exists and already assigned
$client->submit($form, $data); $client->submit($form, $data);
@ -127,7 +127,7 @@ class TagControllerTest extends WallabagCoreTestCase
// re-retrieve the entry to be sure to get fresh data from database (mostly for tags) // re-retrieve the entry to be sure to get fresh data from database (mostly for tags)
$entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId()); $entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId());
$this->assertNotContains($this->tagName, $entry->getTags()); $this->assertNotContains($this->tagName, $entry->getTagsLabel());
$client->request('GET', '/remove-tag/' . $entry->getId() . '/' . $tag->getId()); $client->request('GET', '/remove-tag/' . $entry->getId() . '/' . $tag->getId());

View file

@ -125,7 +125,7 @@ class ElcuratorControllerTest extends WallabagCoreTestCase
$this->assertSame('2015-09-09', $content->getCreatedAt()->format('Y-m-d')); $this->assertSame('2015-09-09', $content->getCreatedAt()->format('Y-m-d'));
$this->assertTrue($content->isStarred(), 'Entry is starred'); $this->assertTrue($content->isStarred(), 'Entry is starred');
$tags = $content->getTags(); $tags = $content->getTagsLabel();
$this->assertContains('tag1', $tags, 'It includes the "tag1" tag'); $this->assertContains('tag1', $tags, 'It includes the "tag1" tag');
$this->assertContains('tag2', $tags, 'It includes the "tag2" tag'); $this->assertContains('tag2', $tags, 'It includes the "tag2" tag');
} }

View file

@ -123,7 +123,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
$this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://www.liberation.fr is ok'); $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://www.liberation.fr is ok');
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.liberation.fr is ok'); $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.liberation.fr is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for https://www.liberation.fr is ok'); $this->assertNotEmpty($content->getLanguage(), 'Language for https://www.liberation.fr is ok');
$this->assertContains('foot', $content->getTags(), 'It includes the "foot" tag'); $this->assertContains('foot', $content->getTagsLabel(), 'It includes the "foot" tag');
$this->assertCount(1, $content->getTags()); $this->assertCount(1, $content->getTags());
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
@ -135,8 +135,8 @@ class InstapaperControllerTest extends WallabagCoreTestCase
$this->getLoggedInUserId() $this->getLoggedInUserId()
); );
$this->assertContains('foot', $content->getTags()); $this->assertContains('foot', $content->getTagsLabel());
$this->assertContains('test_tag', $content->getTags()); $this->assertContains('test_tag', $content->getTagsLabel());
$this->assertCount(2, $content->getTags()); $this->assertCount(2, $content->getTags());
} }

View file

@ -123,7 +123,7 @@ class PinboardControllerTest extends WallabagCoreTestCase
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://ma.ttias.be is ok'); $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://ma.ttias.be is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for https://ma.ttias.be is ok'); $this->assertNotEmpty($content->getLanguage(), 'Language for https://ma.ttias.be is ok');
$tags = $content->getTags(); $tags = $content->getTagsLabel();
$this->assertContains('foot', $tags, 'It includes the "foot" tag'); $this->assertContains('foot', $tags, 'It includes the "foot" tag');
$this->assertContains('varnish', $tags, 'It includes the "varnish" tag'); $this->assertContains('varnish', $tags, 'It includes the "varnish" tag');
$this->assertContains('php', $tags, 'It includes the "php" tag'); $this->assertContains('php', $tags, 'It includes the "php" tag');

View file

@ -123,7 +123,7 @@ class ReadabilityControllerTest extends WallabagCoreTestCase
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.20minutes.fr is ok'); $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.20minutes.fr is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for https://www.20minutes.fr is ok'); $this->assertNotEmpty($content->getLanguage(), 'Language for https://www.20minutes.fr is ok');
$tags = $content->getTags(); $tags = $content->getTagsLabel();
$this->assertContains('foot', $tags, 'It includes the "foot" tag'); $this->assertContains('foot', $tags, 'It includes the "foot" tag');
$this->assertCount(1, $tags); $this->assertCount(1, $tags);

View file

@ -124,7 +124,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
$this->assertSame($content->getPreviewPicture(), 'http://www.framablog.org/public/_img/framablog/wallaby_baby.jpg'); $this->assertSame($content->getPreviewPicture(), 'http://www.framablog.org/public/_img/framablog/wallaby_baby.jpg');
$this->assertEmpty($content->getLanguage(), 'Language for http://www.framablog.org is empty'); $this->assertEmpty($content->getLanguage(), 'Language for http://www.framablog.org is empty');
$tags = $content->getTags(); $tags = $content->getTagsLabel();
$this->assertContains('foot', $tags, 'It includes the "foot" tag'); $this->assertContains('foot', $tags, 'It includes the "foot" tag');
$this->assertContains('framabag', $tags, 'It includes the "framabag" tag'); $this->assertContains('framabag', $tags, 'It includes the "framabag" tag');
$this->assertCount(2, $tags); $this->assertCount(2, $tags);

View file

@ -126,7 +126,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
$this->assertEmpty($content->getPreviewPicture(), 'Preview picture for https://www.liberation.fr is empty'); $this->assertEmpty($content->getPreviewPicture(), 'Preview picture for https://www.liberation.fr is empty');
$this->assertEmpty($content->getLanguage(), 'Language for https://www.liberation.fr is empty'); $this->assertEmpty($content->getLanguage(), 'Language for https://www.liberation.fr is empty');
$tags = $content->getTags(); $tags = $content->getTagsLabel();
$this->assertContains('foot', $tags, 'It includes the "foot" tag'); $this->assertContains('foot', $tags, 'It includes the "foot" tag');
$this->assertCount(1, $tags); $this->assertCount(1, $tags);
@ -143,7 +143,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.mediapart.fr is ok'); $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.mediapart.fr is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for https://www.mediapart.fr is ok'); $this->assertNotEmpty($content->getLanguage(), 'Language for https://www.mediapart.fr is ok');
$tags = $content->getTags(); $tags = $content->getTagsLabel();
$this->assertContains('foot', $tags, 'It includes the "foot" tag'); $this->assertContains('foot', $tags, 'It includes the "foot" tag');
$this->assertContains('mediapart', $tags, 'It includes the "mediapart" tag'); $this->assertContains('mediapart', $tags, 'It includes the "mediapart" tag');
$this->assertContains('blog', $tags, 'It includes the "blog" tag'); $this->assertContains('blog', $tags, 'It includes the "blog" tag');

View file

@ -65,7 +65,7 @@ class ManageControllerTest extends WallabagCoreTestCase
$crawler = $client->followRedirect(); $crawler = $client->followRedirect();
// Check the user has been delete on the list // Check the user has been delete on the list
$this->assertNotRegExp('/Foo User/', $client->getResponse()->getContent()); $this->assertDoesNotMatchRegularExpression('/Foo User/', $client->getResponse()->getContent());
} }
public function testDeleteDisabledForLoggedUser() public function testDeleteDisabledForLoggedUser()