Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Continuous Integration

on:
push:
pull_request:
workflow_dispatch:

jobs:
build:

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-version:
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- '7.4'
- '8.0'
- '8.1'
- '8.2'
- '8.3'
- '8.4'
- '8.5'

name: PHP ${{ matrix.php-version }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions:
coverage: none
# Composer 2.3+ needs PHP 7.2.5; the 2.2 LTS line still runs on 5.6.
tools: ${{ contains(fromJSON('["5.6","7.0","7.1"]'), matrix.php-version) && 'composer:v2.2' || 'composer:v2' }}

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-php${{ matrix.php-version }}-composer-

# update, not install: no lock file is committed, so each PHP version
# resolves the PHPUnit and polyfill versions that support it.
- name: Install dependencies
run: composer update --no-interaction --prefer-dist

- name: Validate composer.json
run: composer validate --no-check-lock --no-check-publish

- name: Run test suite
run: ./vendor/bin/phpunit
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Releasing this package: Actions -> Release -> Run workflow, pick the branch
# (2.x) and type the version. Or from a terminal:
#
# gh workflow run release.yml --ref 2.x -f version=2.0.5
#
# The shared workflow creates the tag itself, and only after every check has
# passed. Do not tag by hand -- Packagist derives versions from tags, so a tag
# is a published version the moment it exists.
#
# Release notes come from this package's own CHANGES.md. The version you type
# must match the version at the top of the change log -- or, for a pre-release
# such as 2.0.5-alpha1, its base version, so that alphas and betas do not each
# need a change log section of their own.

name: Release

on:
workflow_dispatch:
inputs:
version:
description: 'Version to release, e.g. 2.0.5'
required: true
type: string

jobs:
release:
uses: auraphp/bin/.github/workflows/release.yml@v1.0.0
permissions:
contents: write
with:
version: ${{ inputs.version }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/composer.lock
/vendor
/phpunit.xml
/.phpunit.result.cache
33 changes: 33 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
# CHANGELOG

## 2.0.5

Maintenance release: the package now has continuous integration, and a
release workflow, for the first time.

- The test suite was written against the PHPUnit 4/5 API
(`PHPUnit_Framework_TestCase`, `setExpectedException()`), which PHPUnit 6
removed, so it could not run on any supported PHP at all. It now runs on
PHP 5.6 through 8.5: 11 tests, 17 assertions.
- ADD: `phpunit/phpunit` and `yoast/phpunit-polyfills` to `require-dev`.
The package had no test runner declared at all, so `composer install`
produced nothing to run the tests with.
- ADD: a Continuous Integration workflow, and a Release workflow calling the
shared `auraphp/bin` workflow.
- FIX: the `nds()` test helper stringified the nested base-dir arrays from
`getPrefixes()` to `'Array'` instead of recursing into them, so
`testAddPrefix` could never pass. The library itself was correct.
- The suite runs on **PHP 5.6 through 8.5**, via
[`yoast/phpunit-polyfills`][polyfills], which lets one set of tests run on
PHPUnit 5.7 through 11. Tests use `set_up()` rather than `setUp(): void`,
because the `void` return type is a parse error before PHP 7.1.
- `phpunit.xml.dist` is deliberately minimal, so that a single config file is
valid for every PHPUnit version in that range.

[polyfills]: https://github.com/Yoast/PHPUnit-Polyfills

No library code changed. `require.php` is unchanged, so nothing changes for
consumers of this package.

## 2.0.4

Hygiene release: update the license year, and remove a branch alias.
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
"Aura\\Autoload\\": "src/"
}
},
"require-dev": {
"phpunit/phpunit": "^5.7.21 || ^6.4.4 || ^7.5 || ^8.5 || ^9.6 || ^11.0",
"yoast/phpunit-polyfills": "^2.0.5 || ^3.1.2 || ^4.0.0"
},
"extra": {
"aura": {
"type": "library"
Expand Down
6 changes: 4 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<phpunit bootstrap="./phpunit.php">
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./phpunit.php"
colors="true">
<testsuites>
<testsuite>
<testsuite name="Aura.Autoload">
<directory>./tests</directory>
</testsuite>
</testsuites>
Expand Down
13 changes: 10 additions & 3 deletions tests/LoaderTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
namespace Aura\Autoload;

class LoaderTest extends \PHPUnit_Framework_TestCase
class LoaderTest extends \Yoast\PHPUnitPolyfills\TestCases\TestCase
{
protected $loader;

protected $base_dir;

protected function setup()
protected function set_up()
{
$this->loader = new Loader;
}
Expand Down Expand Up @@ -195,9 +195,16 @@ public function testPsr0Loading()
$this->assertSame($expect, $actual);
}

// normalize directory separators in file names for windows compatibilitys
// normalize directory separators in file names for windows compatibility.
// recurses, because getPrefixes() returns base dirs nested one level under
// each prefix -- str_replace() on a nested array stringifies the inner
// arrays to 'Array' instead of descending into them.
protected function nds($file)
{
if (is_array($file)) {
return array_map(array($this, 'nds'), $file);
}

return str_replace('/', DIRECTORY_SEPARATOR, $file);
}
}
Loading