Skip to content

Commit

Permalink
CI switched to GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
remorhaz committed Sep 19, 2023
1 parent ec4d0aa commit 4de54d9
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 54 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

* text text=auto eol=lf

.php diff=php
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build

on:
- push
- workflow_dispatch

jobs:
tests:
name: PHP ${{ matrix.php-version }} on ${{ matrix.os }} (${{ matrix.composer-options }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php-version:
- "8.0"
- "8.1"
- "8.2"
os:
- ubuntu-latest
- windows-latest
- macOS-latest
composer-options:
- ""
- "--prefer-lowest"
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Validate composer.json and composer.lock
run: composer validate

- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: intl
coverage: xdebug
ini-values: error_reporting=E_ALL

- name: Install dependencies
run: composer update
--prefer-dist
--no-progress
${{ matrix.composer-options }}

- name: Build application
run: composer build

- name: Run tests
run: composer test
27 changes: 0 additions & 27 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# PHP JSON Pointer

[![Latest Stable Version](https://poser.pugx.org/remorhaz/php-json-pointer/v/stable)](https://packagist.org/packages/remorhaz/php-json-pointer)
[![Build Status](https://travis-ci.org/remorhaz/php-json-pointer.svg?branch=master)](https://travis-ci.org/remorhaz/php-json-pointer)
[![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)
[![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)
[![codecov](https://codecov.io/gh/remorhaz/php-json-pointer/branch/master/graph/badge.svg)](https://codecov.io/gh/remorhaz/php-json-pointer)
[![Infection MSI](https://badge.stryker-mutator.io/github.com/remorhaz/php-json-pointer/master)](https://infection.github.io)
Expand All @@ -11,7 +11,7 @@
This library implements [RFC6901](https://tools.ietf.org/html/rfc6901)-compliant JSON pointers.

## Requirements
* PHP 7.3+
* PHP 8

## Features
* Selecting part of a JSON document.
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"remorhaz/php-unilex": "^0.5.2"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"infection/infection": "^0.18",
"squizlabs/php_codesniffer": "^3.5"
"phpunit/phpunit": "^9.6.13 || ^10",
"infection/infection": "^0.26.19 || ^0.27.2",
"squizlabs/php_codesniffer": "^3.7.2"
},
"autoload": {
"psr-4": {
Expand Down
14 changes: 10 additions & 4 deletions tests/Parser/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,20 @@ public function testBuildLocator_ConstructedWithReferenceFactory_UsesSameInstanc
{
$referenceFactory = $this->createMock(ReferenceFactoryInterface::class);
$parser = new Parser(new Ll1ParserFactory(), $referenceFactory);
$textBuffer = [];
$referenceFactory
->expects(self::exactly(2))
->method('createReference')
->withConsecutive(
['a'],
['1']
->with(
self::callback(
function (string $text) use (&$textBuffer): bool {
$textBuffer[] = $text;

return true;
},
),
);
$parser->buildLocator('/a/1');
self::assertSame(['a', '1'], $textBuffer);
}

/**
Expand Down
45 changes: 27 additions & 18 deletions tests/Parser/TranslationSchemeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
class TranslationSchemeTest extends TestCase
{
/**
* @param string $source
* @param list<list<string>> $expectedValues
* @param string $source
* @param list<string> $expectedValues
* @throws UniLexException
* @dataProvider providerValidBuffer
*/
Expand All @@ -37,11 +37,20 @@ public function testTranslation_ValidBuffer_BuildsMatchingLocator(string $source
$scheme = new TranslationScheme($locatorBuilder);
$parser = $this->createParser($scheme, $source);

$textBuffer = [];
$locatorBuilder
->expects(self::exactly(count($expectedValues)))
->method('addReference')
->withConsecutive(...$expectedValues);
->with(
self::callback(
function (string $text) use (&$textBuffer): bool {
$textBuffer[] = $text;

return true;
},
),
);
$parser->run();
self::assertSame($expectedValues, $textBuffer);
}

/**
Expand All @@ -66,25 +75,25 @@ private function createParser(TranslationSchemeInterface $scheme, string $source
}

/**
* @return iterable<string, array{string, list<list<string>>}>
* @return iterable<string, array{string, list<string>}>
*/
public static function providerValidBuffer(): iterable
{
return [
'Empty string' => ['', []],
'Empty property' => ['/', [['']]],
'Single alpha property' => ['/a', [['a']]],
'Single numeric property' => ['/1', [['1']]],
'Single non-ASCII property' => ['', [['б']]],
'Property sequence' => ['/a/1', [['a'], ['1']]],
'Escaped property sequence' => ['/~0/~1', [['~'], ['/']]],
'Escaped tilde in a word' => ['/a~0b', [['a~b']]],
'Escaped tilde in a word before zero' => ['/a~00', [['a~0']]],
'Escaped tilde in a word before one' => ['/a~01', [['a~1']]],
'Escaped slash in a word' => ['/a~1b', [['a/b']]],
'Escaped slash in a word before zero' => ['/a~10', [['a/0']]],
'Escaped tilde then escaped slash' => ['/~0~1', [['~/']]],
'Escaped slash then escaped tilde' => ['/~1~0', [['/~']]],
'Empty property' => ['/', ['']],
'Single alpha property' => ['/a', ['a']],
'Single numeric property' => ['/1', ['1']],
'Single non-ASCII property' => ['', ['б']],
'Property sequence' => ['/a/1', ['a', '1']],
'Escaped property sequence' => ['/~0/~1', ['~', '/']],
'Escaped tilde in a word' => ['/a~0b', ['a~b']],
'Escaped tilde in a word before zero' => ['/a~00', ['a~0']],
'Escaped tilde in a word before one' => ['/a~01', ['a~1']],
'Escaped slash in a word' => ['/a~1b', ['a/b']],
'Escaped slash in a word before zero' => ['/a~10', ['a/0']],
'Escaped tilde then escaped slash' => ['/~0~1', ['~/']],
'Escaped slash then escaped tilde' => ['/~1~0', ['/~']],
];
}

Expand Down

0 comments on commit 4de54d9

Please sign in to comment.