Skip to content

Commit bfaeb49

Browse files
authored
Merge pull request #6 from Rareloop/support-php8
Add PHP8 support
2 parents 5521a1f + 3f1e176 commit bfaeb49

File tree

11 files changed

+81
-80
lines changed

11 files changed

+81
-80
lines changed

.github/workflows/ci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build-test:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
php_version: [7.3, 7.4, 8.0]
11+
composer_flags: ["", "--prefer-lowest"]
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Setup PHP
17+
uses: shivammathur/setup-php@v2
18+
with:
19+
php-version: ${{ matrix.php_version }}
20+
extensions: xdebug
21+
22+
- name: Install dependencies
23+
uses: php-actions/composer@v5
24+
with:
25+
php_version: ${{ matrix.php_version }}
26+
args: ${{ matrix.composer_flags }}
27+
command: update
28+
29+
- name: Run tests
30+
run: ./vendor/bin/phpunit --coverage-clover ./tests/logs/clover.xml
31+
env:
32+
XDEBUG_MODE: coverage
33+
34+
- name: Run Codesniffer
35+
run: vendor/bin/phpcs --standard=PSR2 ./src
36+
37+
# - name: Submit coverage to Coveralls
38+
# # We use php-coveralls library for this, as the official Coveralls GitHub Action lacks support for clover reports:
39+
# # https://github.com/coverallsapp/github-action/issues/15
40+
# env:
41+
# COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
# COVERALLS_PARALLEL: true
43+
# COVERALLS_FLAG_NAME: ${{ github.job }}-PHP-${{ matrix.php_version }} ${{ matrix.composer_flags }}
44+
# run: |
45+
# composer global require php-coveralls/php-coveralls
46+
# ~/.composer/vendor/bin/php-coveralls -v

.travis.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

composer.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
{
22
"name": "rareloop/primer-core",
33
"require": {
4-
"php": ">=7.1.3",
4+
"php": ">=7.3",
55
"symfony/finder": "^4.2.5|^5.0",
66
"twig/twig": "^2.6",
7-
"tightenco/collect": "^5.7.0",
7+
"tightenco/collect": "^5.6.0",
88
"league/commonmark": "^1.5",
99
"mnapoli/front-yaml": "^1.6"
1010
},
1111
"require-dev": {
12-
"phpunit/phpunit": "^6.0",
12+
"phpunit/phpunit": "^9.0",
1313
"php-coveralls/php-coveralls": "^2.0",
14-
"mockery/mockery": "^1.0.0",
15-
"squizlabs/php_codesniffer": "^3.3.1",
16-
"codedungeon/phpunit-result-printer": "^0.19.13",
17-
"codedungeon/php-cli-colors": "^1.10.7",
18-
"mikey179/vfsstream": "^1.6",
14+
"mockery/mockery": "^1.4.4",
15+
"squizlabs/php_codesniffer": "^3.6.0",
16+
"mikey179/vfsstream": "^1.6.9",
1917
"antecedent/patchwork": "^2.1.8"
2018
},
2119
"autoload": {

phpunit-printer.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

phpunit.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
convertNoticesToExceptions="true"
99
convertWarningsToExceptions="true"
1010
processIsolation="false"
11-
stopOnFailure="false"
12-
printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer">
11+
stopOnFailure="false">
1312
<testsuites>
1413
<testsuite name="Primer Test Suite">
1514
<directory>tests</directory>

tests/DocumentParsers/MarkdownDocumentParserTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function indents_are_not_treated_as_code_blocks()
3636

3737
$outputDoc = $parser->parse($doc);
3838

39-
$this->assertNotContains('<pre><code>', $outputDoc->content());
40-
$this->assertNotContains('</code></pre>', $outputDoc->content());
39+
$this->assertStringNotContainsString('<pre><code>', $outputDoc->content());
40+
$this->assertStringNotContainsString('</code></pre>', $outputDoc->content());
4141
}
4242
}

tests/FileSystemDocumentProviderTest.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,10 @@ public function can_get_document_that_is_numerically_ordered()
174174
$this->assertSame('01-building.md', $pattern2->content());
175175
}
176176

177-
/**
178-
* @test
179-
* @expectedException Rareloop\Primer\Exceptions\DocumentNotFoundException
180-
*/
177+
/** @test */
181178
public function getDocument_throws_exception_if_document_does_not_exist()
182179
{
180+
$this->expectException(\Rareloop\Primer\Exceptions\DocumentNotFoundException::class);
183181
vfsStream::setup();
184182
$root = vfsStream::create([
185183
'foo' => [
@@ -202,12 +200,11 @@ public function allDocumentIds_does_not_fall_over_if_no_paths_are_provided()
202200
$this->assertSame([], $dataProvider->allDocumentIds());
203201
}
204202

205-
/**
206-
* @test
207-
* @expectedException Rareloop\Primer\Exceptions\DocumentNotFoundException
208-
*/
203+
/** @test */
209204
public function getDocument_does_not_fall_over_if_no_paths_are_provided()
210205
{
206+
$this->expectException(\Rareloop\Primer\Exceptions\DocumentNotFoundException::class);
207+
211208
$dataProvider = new FileSystemDocumentProvider([], 'md');
212209

213210
$dataProvider->getDocument('not/found');

tests/FileSystemPatternProviderTest.php

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,11 @@ public function can_get_template_contents()
109109
$this->assertSame('<footer>Hello World</footer>', $dataProvider->getPatternTemplate('components/misc/footer'));
110110
}
111111

112-
/**
113-
* @test
114-
* @expectedException Rareloop\Primer\Exceptions\PatternNotFoundException
115-
*/
112+
/** @test */
116113
public function can_not_get_template_contents_if_partial_id_provided()
117114
{
115+
$this->expectException(\Rareloop\Primer\Exceptions\PatternNotFoundException::class);
116+
118117
vfsStream::setup();
119118
$root = vfsStream::create([
120119
'foo' => [
@@ -215,12 +214,11 @@ public function can_check_if_state_data_exists_for_a_pattern_as_php()
215214
$this->assertFalse($dataProvider->patternHasState('components/misc/header', 'unexpected'));
216215
}
217216

218-
/**
219-
* @test
220-
* @expectedException Rareloop\Primer\Exceptions\PatternNotFoundException
221-
*/
217+
/** @test */
222218
public function patternHasState_throws_exception_if_pattern_does_not_exist()
223219
{
220+
$this->expectException(\Rareloop\Primer\Exceptions\PatternNotFoundException::class);
221+
224222
vfsStream::setup();
225223
$root = vfsStream::create([
226224
'foo' => [
@@ -535,12 +533,11 @@ public function getPatternStateData_returns_empty_array_when_no_data_is_availabl
535533
$this->assertSame([], $data);
536534
}
537535

538-
/**
539-
* @test
540-
* @expectedException Rareloop\Primer\Exceptions\PatternNotFoundException
541-
*/
536+
/** @test */
542537
public function getPatternStateData_throws_exception_when_pattern_is_invalid()
543538
{
539+
$this->expectException(\Rareloop\Primer\Exceptions\PatternNotFoundException::class);
540+
544541
vfsStream::setup();
545542
$root = vfsStream::create([
546543
'foo' => [
@@ -592,12 +589,11 @@ public function getPatternStateData_does_not_fall_over_if_no_paths_are_provided(
592589
$this->assertSame([], $dataProvider->getPatternStateData('not/found', 'state'));
593590
}
594591

595-
/**
596-
* @test
597-
* @expectedException Rareloop\Primer\Exceptions\PatternNotFoundException
598-
*/
592+
/** @test */
599593
public function getPattern_does_not_fall_over_if_no_paths_are_provided()
600594
{
595+
$this->expectException(\Rareloop\Primer\Exceptions\PatternNotFoundException::class);
596+
601597
$dataProvider = new FileSystemPatternProvider([], 'md');
602598

603599
$dataProvider->getPattern('not/found');

tests/MenuTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,11 @@ public function can_test_if_a_section_exists()
5656
$this->assertFalse($menu->hasSection('templates'));
5757
}
5858

59-
/**
60-
* @test
61-
* @expectedException Rareloop\Primer\Exceptions\SectionNotFoundException
62-
*/
59+
/** @test */
6360
public function getSection_throws_an_exception_if_section_is_not_found()
6461
{
62+
$this->expectException(\Rareloop\Primer\Exceptions\SectionNotFoundException::class);
63+
6564
$menu = new Menu();
6665
$menu->getSection('patterns');
6766
}

tests/PrimerTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,11 @@ public function correct_patterns_are_rendered_when_one_name_is_contained_in_anot
355355
$this->assertSame('<p>Testing123</p>', $primer->renderPatterns('components/misc/header'));
356356
}
357357

358-
/**
359-
* @test
360-
* @expectedException Rareloop\Primer\Exceptions\PatternNotFoundException
361-
*/
358+
/** @test */
362359
public function renderPatterns_throws_exception_if_no_matching_patterns_are_found()
363360
{
361+
$this->expectException(\Rareloop\Primer\Exceptions\PatternNotFoundException::class);
362+
364363
$patternIds = [
365364
'components/misc/header',
366365
'components/misc/footer',

0 commit comments

Comments
 (0)