Skip to content

Commit b9a672f

Browse files
authored
Fix test matrix, use Ubuntu 20.04 (#37)
Switch GitHub Actions to Ubuntu 20.04 and make sure matrix tests really use the indicated PHP versions
1 parent ec4dae9 commit b9a672f

File tree

7 files changed

+46
-45
lines changed

7 files changed

+46
-45
lines changed

.github/workflows/fix-cs-php.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# Update this by running
2-
# curl https://gist.githubusercontent.com/mpdude/ca93a185bcbf56eb7e341632ad4f8263/raw/fix-cs-php.yml > .github/workflows/fix-cs-php.yml
3-
41
on:
52
push:
63
branches:

.github/workflows/lint.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
cat <<< $(jq --arg version $VERSION '.require |= with_entries(if ((.key|test("^symfony/monolog")|not) and (.key|test("^symfony/"))) then .value=$version else . end)' < composer.json) > composer.json

.github/workflows/tests.yml

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,39 @@
1-
name: Run Tests
1+
name: Tests
22

33
on:
44
push:
5-
branches:
5+
branches:
66
- master
77
pull_request:
88

9+
env:
10+
SYMFONY_DEPRECATIONS_HELPER: weak
11+
912
jobs:
1013
PHPUnit:
11-
runs-on: ubuntu-18.04
14+
runs-on: ubuntu-20.04
1215
strategy:
1316
fail-fast: false
1417
matrix:
15-
php: [7.2, 7.3, 7.4]
18+
include:
19+
- { php-version: 7.2, symfony-locked-version: none, dependency-version: prefer-lowest }
20+
- { php-version: 7.4, symfony-locked-version: 4.4.*, dependency-version: prefer-stable }
21+
- { php-version: 8.1, symfony-locked-version: none, dependency-version: prefer-stable }
22+
name: PHPUnit (PHP ${{matrix.php-version}}, Symfony Version Lock ${{ matrix.symfony-locked-version }}, ${{ matrix.dependency-version }})
1623
steps:
1724
- uses: actions/checkout@v2
18-
- run: composer install --no-interaction --no-scripts --no-progress --no-suggest
19-
- run: mkdir -p build/logs
20-
- run: vendor/bin/phpunit --coverage-clover=build/logs/clover.xml
21-
# Commented out Coveralls reporting until https://github.com/php-coveralls/php-coveralls/pull/275 is resolved
22-
#- run: tools/php-coveralls --verbose
23-
# env:
24-
# COVERALLS_RUN_LOCALLY: 1
25-
# COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
25+
- uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: ${{ matrix.php-version }}
28+
tools: composer:v2
29+
- uses: actions/cache@v2
30+
with:
31+
path: vendor
32+
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.symfony-locked-version }}-${{ matrix.dependency-version }}-${{ hashFiles('composer.json') }}
33+
restore-keys: |
34+
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.symfony-locked-version }}-${{ matrix.dependency-version }}-
35+
- run: VERSION=${{ matrix.symfony-locked-version }} .github/workflows/lock-symfony-version.sh
36+
if: matrix.symfony-locked-version != 'none'
37+
- run: composer update --${{ matrix.dependency-version }} --no-interaction --no-scripts --no-progress --ansi
38+
- run: composer show
39+
- run: vendor/bin/phpunit

Tests/Twig/ExtensionIntegrationTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public function testExpressionGetsTransformedByTwigEnvironment()
2222

2323
$output = $this->renderWithExtension('{{ piwik_code() }}', new Extension(false, $siteId, $hostname, false));
2424

25-
$this->assertContains((string) $siteId, $output);
26-
$this->assertContains($hostname, $output);
25+
self::assertStringContainsString((string) $siteId, $output);
26+
self::assertStringContainsString($hostname, $output);
2727
}
2828

2929
public function testCustomApiCallsThroughPiwikFunction()
@@ -33,7 +33,7 @@ public function testCustomApiCallsThroughPiwikFunction()
3333
{{ piwik_code() }}
3434
", new Extension(false, 1, 'my.host', false));
3535

36-
$this->assertContains('["foo","bar","baz"]', $output);
36+
self::assertStringContainsString('["foo","bar","baz"]', $output);
3737
}
3838

3939
private function renderWithExtension($templateString, ExtensionInterface $extension)

Tests/Twig/ExtensionTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,26 @@ class ExtensionTest extends TestCase
1010
public function testPiwikCodeReturnsNoScriptWhenDisabled()
1111
{
1212
$extension = new Extension(true, 1, '', false);
13-
$this->assertNotContains('script', $extension->piwikCode());
13+
self::assertStringNotContainsString('script', $extension->piwikCode());
1414
}
1515

1616
public function testPiwikCodeReturnsScript()
1717
{
1818
$extension = new Extension(false, 1, '', false);
19-
$this->assertContains('script', $extension->piwikCode());
19+
self::assertStringContainsString('script', $extension->piwikCode());
2020
}
2121

2222
public function testPiwikCodeContainsSiteId()
2323
{
2424
$siteId = 1234;
2525
$extension = new Extension(false, $siteId, '', false);
26-
$this->assertContains((string) $siteId, $extension->piwikCode());
26+
self::assertStringContainsString((string) $siteId, $extension->piwikCode());
2727
}
2828

2929
public function testPiwikCodeContainsApiURL()
3030
{
3131
$extension = new Extension(false, 1, 'my.host', '/js/');
32-
$this->assertContains('_paq.push([\'setAPIUrl\', u]);', $extension->piwikCode());
32+
self::assertStringContainsString('_paq.push([\'setAPIUrl\', u]);', $extension->piwikCode());
3333
}
3434

3535
public function testPiwikCodeDoesNotContainApiURL()
@@ -38,39 +38,39 @@ public function testPiwikCodeDoesNotContainApiURL()
3838
$hostname = 'myHost.de';
3939
$path = 'piwik.php';
4040
$extension = new Extension(false, $siteId, $hostname, $path);
41-
$this->assertNotContains('_paq.push([\'setAPIUrl\', u]);', $extension->piwikCode());
41+
self::assertStringNotContainsString('_paq.push([\'setAPIUrl\', u]);', $extension->piwikCode());
4242
}
4343

4444
public function testPiwikCodeContainsHostName()
4545
{
4646
$hostname = 'myHost.de';
4747
$extension = new Extension(false, 1, $hostname, false);
48-
$this->assertContains($hostname, $extension->piwikCode());
48+
self::assertStringContainsString($hostname, $extension->piwikCode());
4949
}
5050

5151
public function testAdditionalApiCallsCanBeAdded()
5252
{
5353
$extension = new Extension(false, 1, 'my.host', false);
5454
$extension->piwikPush('foo', 'bar', 'baz');
55-
$this->assertContains('["foo","bar","baz"]', $extension->piwikCode());
55+
self::assertStringContainsString('["foo","bar","baz"]', $extension->piwikCode());
5656
}
5757

5858
public function testTrackPageViewEnabledByDefault()
5959
{
6060
$extension = new Extension(false, 1, 'my.host', false);
61-
$this->assertContains('"trackPageView"', $extension->piwikCode());
61+
self::assertStringContainsString('"trackPageView"', $extension->piwikCode());
6262
}
6363

6464
public function testCookiesCanBeDisabled()
6565
{
6666
$extension = new Extension(false, 1, 'my.host', false);
67-
$this->assertContains('"disableCookies"', $extension->piwikCode());
67+
self::assertStringContainsString('"disableCookies"', $extension->piwikCode());
6868
}
6969

7070
public function testCookiesCanBeEnabled()
7171
{
7272
$extension = new Extension(false, 1, 'my.host', false, false);
73-
$this->assertNotContains('"disableCookies"', $extension->piwikCode());
73+
self::assertStringNotContainsString('"disableCookies"', $extension->piwikCode());
7474
}
7575

7676
public function testTrackSiteSearchDisablesPageTracking()
@@ -79,8 +79,8 @@ public function testTrackSiteSearchDisablesPageTracking()
7979
$extension->piwikPush('trackSiteSearch', 'Banana', 'Organic Food', 42);
8080

8181
$code = $extension->piwikCode();
82-
$this->assertContains('"trackSiteSearch"', $code);
83-
$this->assertNotContains('"trackPageView"', $code);
82+
self::assertStringContainsString('"trackSiteSearch"', $code);
83+
self::assertStringNotContainsString('"trackPageView"', $code);
8484
}
8585

8686
public function testIsTwigExtension()

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"twig/twig": "^1.34|^2.0|^3.0"
3030
},
3131
"require-dev": {
32-
"phpunit/phpunit": "~7.0",
33-
"symfony/phpunit-bridge": "*"
32+
"phpunit/phpunit": "^8.5",
33+
"symfony/phpunit-bridge": ">= 4.4"
3434
},
3535
"config": {
3636
"sort-packages": true

0 commit comments

Comments
 (0)