Skip to content

Commit f97d04f

Browse files
committed
CI switched to GitHub Actions
1 parent ec4d0aa commit f97d04f

File tree

8 files changed

+96
-54
lines changed

8 files changed

+96
-54
lines changed

.gitattributes

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
* text text=auto eol=lf
3+
4+
.php diff=php

.github/workflows/build.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Build
2+
3+
on:
4+
- push
5+
- workflow_dispatch
6+
7+
jobs:
8+
tests:
9+
name: PHP ${{ matrix.php-version }} on ${{ matrix.os }} (${{ matrix.composer-options }})
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php-version:
15+
- "8.0"
16+
- "8.1"
17+
- "8.2"
18+
os:
19+
- ubuntu-latest
20+
- macOS-latest
21+
composer-options:
22+
- ""
23+
- "--prefer-lowest"
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v3
27+
28+
- name: Validate composer.json and composer.lock
29+
run: composer validate
30+
31+
- name: Set up PHP ${{ matrix.php-version }}
32+
uses: shivammathur/setup-php@v2
33+
with:
34+
php-version: ${{ matrix.php-version }}
35+
extensions: intl
36+
coverage: xdebug
37+
ini-values: error_reporting=E_ALL
38+
39+
- name: Install dependencies
40+
run: composer update
41+
--prefer-dist
42+
--no-progress
43+
${{ matrix.composer-options }}
44+
45+
- name: Build application
46+
run: composer build
47+
48+
- name: Run tests
49+
run: composer test

.travis.yml

-27
This file was deleted.

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# PHP JSON Pointer
22

33
[![Latest Stable Version](https://poser.pugx.org/remorhaz/php-json-pointer/v/stable)](https://packagist.org/packages/remorhaz/php-json-pointer)
4-
[![Build Status](https://travis-ci.org/remorhaz/php-json-pointer.svg?branch=master)](https://travis-ci.org/remorhaz/php-json-pointer)
4+
[![Build](https://github.com/remorhaz/php-json-pointer/actions/workflows/build.yml/badge.svg)](https://github.com/remorhaz/php-json-pointer/actions/workflows/build.yml)
55
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/remorhaz/php-json-pointer/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/remorhaz/php-json-pointer/?branch=master)
66
[![codecov](https://codecov.io/gh/remorhaz/php-json-pointer/branch/master/graph/badge.svg)](https://codecov.io/gh/remorhaz/php-json-pointer)
77
[![Infection MSI](https://badge.stryker-mutator.io/github.com/remorhaz/php-json-pointer/master)](https://infection.github.io)
@@ -11,7 +11,7 @@
1111
This library implements [RFC6901](https://tools.ietf.org/html/rfc6901)-compliant JSON pointers.
1212

1313
## Requirements
14-
* PHP 7.3+
14+
* PHP 8
1515

1616
## Features
1717
* Selecting part of a JSON document.

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
"remorhaz/php-unilex": "^0.5.2"
2323
},
2424
"require-dev": {
25-
"phpunit/phpunit": "^9.5",
26-
"infection/infection": "^0.18",
27-
"squizlabs/php_codesniffer": "^3.5"
25+
"phpunit/phpunit": "^9.6.13 || ^10",
26+
"infection/infection": "^0.26.19 || ^0.27.2",
27+
"squizlabs/php_codesniffer": "^3.7.2"
2828
},
2929
"autoload": {
3030
"psr-4": {

spec/GrammarSpec.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace Remorhaz\JSON\Pointer;

tests/Parser/ParserTest.php

+10-4
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,20 @@ public function testBuildLocator_ConstructedWithReferenceFactory_UsesSameInstanc
6969
{
7070
$referenceFactory = $this->createMock(ReferenceFactoryInterface::class);
7171
$parser = new Parser(new Ll1ParserFactory(), $referenceFactory);
72+
$textBuffer = [];
7273
$referenceFactory
73-
->expects(self::exactly(2))
7474
->method('createReference')
75-
->withConsecutive(
76-
['a'],
77-
['1']
75+
->with(
76+
self::callback(
77+
function (string $text) use (&$textBuffer): bool {
78+
$textBuffer[] = $text;
79+
80+
return true;
81+
},
82+
),
7883
);
7984
$parser->buildLocator('/a/1');
85+
self::assertSame(['a', '1'], $textBuffer);
8086
}
8187

8288
/**

tests/Parser/TranslationSchemeTest.php

+27-18
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
class TranslationSchemeTest extends TestCase
2727
{
2828
/**
29-
* @param string $source
30-
* @param list<list<string>> $expectedValues
29+
* @param string $source
30+
* @param list<string> $expectedValues
3131
* @throws UniLexException
3232
* @dataProvider providerValidBuffer
3333
*/
@@ -37,11 +37,20 @@ public function testTranslation_ValidBuffer_BuildsMatchingLocator(string $source
3737
$scheme = new TranslationScheme($locatorBuilder);
3838
$parser = $this->createParser($scheme, $source);
3939

40+
$textBuffer = [];
4041
$locatorBuilder
41-
->expects(self::exactly(count($expectedValues)))
4242
->method('addReference')
43-
->withConsecutive(...$expectedValues);
43+
->with(
44+
self::callback(
45+
function (string $text) use (&$textBuffer): bool {
46+
$textBuffer[] = $text;
47+
48+
return true;
49+
},
50+
),
51+
);
4452
$parser->run();
53+
self::assertSame($expectedValues, $textBuffer);
4554
}
4655

4756
/**
@@ -66,25 +75,25 @@ private function createParser(TranslationSchemeInterface $scheme, string $source
6675
}
6776

6877
/**
69-
* @return iterable<string, array{string, list<list<string>>}>
78+
* @return iterable<string, array{string, list<string>}>
7079
*/
7180
public static function providerValidBuffer(): iterable
7281
{
7382
return [
7483
'Empty string' => ['', []],
75-
'Empty property' => ['/', [['']]],
76-
'Single alpha property' => ['/a', [['a']]],
77-
'Single numeric property' => ['/1', [['1']]],
78-
'Single non-ASCII property' => ['', [['б']]],
79-
'Property sequence' => ['/a/1', [['a'], ['1']]],
80-
'Escaped property sequence' => ['/~0/~1', [['~'], ['/']]],
81-
'Escaped tilde in a word' => ['/a~0b', [['a~b']]],
82-
'Escaped tilde in a word before zero' => ['/a~00', [['a~0']]],
83-
'Escaped tilde in a word before one' => ['/a~01', [['a~1']]],
84-
'Escaped slash in a word' => ['/a~1b', [['a/b']]],
85-
'Escaped slash in a word before zero' => ['/a~10', [['a/0']]],
86-
'Escaped tilde then escaped slash' => ['/~0~1', [['~/']]],
87-
'Escaped slash then escaped tilde' => ['/~1~0', [['/~']]],
84+
'Empty property' => ['/', ['']],
85+
'Single alpha property' => ['/a', ['a']],
86+
'Single numeric property' => ['/1', ['1']],
87+
'Single non-ASCII property' => ['', ['б']],
88+
'Property sequence' => ['/a/1', ['a', '1']],
89+
'Escaped property sequence' => ['/~0/~1', ['~', '/']],
90+
'Escaped tilde in a word' => ['/a~0b', ['a~b']],
91+
'Escaped tilde in a word before zero' => ['/a~00', ['a~0']],
92+
'Escaped tilde in a word before one' => ['/a~01', ['a~1']],
93+
'Escaped slash in a word' => ['/a~1b', ['a/b']],
94+
'Escaped slash in a word before zero' => ['/a~10', ['a/0']],
95+
'Escaped tilde then escaped slash' => ['/~0~1', ['~/']],
96+
'Escaped slash then escaped tilde' => ['/~1~0', ['/~']],
8897
];
8998
}
9099

0 commit comments

Comments
 (0)