Skip to content

Commit

Permalink
Merge pull request #855 from spatie/fix-test-suite
Browse files Browse the repository at this point in the history
Fix test suite
  • Loading branch information
Gummibeer authored Mar 2, 2021
2 parents ade270f + 347de92 commit 5b49512
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 114 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/composer-normalize.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
name: normalize composer.json

on:
push:
paths:
- 'composer.json'
push:
paths:
- "composer.json"

jobs:
normalize:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v2
normalize:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v2

- name: normalize composer.json
run: |
composer global require ergebnis/composer-normalize
composer normalize
- name: normalize composer.json
run: |
composer global require ergebnis/composer-normalize
composer normalize
- uses: stefanzweifel/git-auto-commit-action@v4.0.0
with:
commit_message: normalize composer.json
- uses: stefanzweifel/git-auto-commit-action@v4.0.0
with:
commit_message: normalize composer.json
26 changes: 13 additions & 13 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: Check & fix styling

on: [ push ]
on: [push]

jobs:
php-cs-fixer:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}

- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php_cs.dist --allow-risky=yes
- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php_cs.dist --allow-risky=yes

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Fix styling
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Fix styling
72 changes: 34 additions & 38 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'
- cron: "0 0 * * *"

jobs:
test:
Expand All @@ -13,45 +13,41 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ 8.0, 7.4, 7.3, 7.2 ]
laravel: [ 8.*, 7.*, 6.* ]
dependency-version: [ prefer-lowest, prefer-stable ]
os: [ ubuntu-latest, windows-latest ]
php: ["8.0", "7.4", "7.3"]
laravel: [8.*, 7.*, 6.*]
dependency-version: [prefer-lowest, prefer-stable]
os: [ubuntu-latest, windows-latest]
include:
- laravel: 8.*
testbench: 6.*
- laravel: 7.*
testbench: 5.*
- laravel: 6.*
testbench: 4.*
exclude:
- laravel: 8.*
php: 7.2
- laravel: 8.*
testbench: 6.*
- laravel: 7.*
testbench: 5.*
- laravel: 6.*
testbench: 4.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
- name: Execute tests
run: vendor/bin/phpunit

- name: Checkout code
uses: actions/checkout@v2

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
- name: Execute tests
run: vendor/bin/phpunit
26 changes: 13 additions & 13 deletions .github/workflows/stale-issues.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: "Close stale issues"
on:
schedule:
- cron: "0 0 * * *"
schedule:
- cron: "0 0 * * *"

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v2.0.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days'
stale-issue-label: 'stale'
exempt-issue-labels: 'bug,enhancement,help wanted,next release,revisit for next major version'
days-before-stale: 21
days-before-close: 7
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v2.0.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: "This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days"
stale-issue-label: "stale"
exempt-issue-labels: "bug,enhancement,help wanted,next release,revisit for next major version"
days-before-stale: 21
days-before-close: 7
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

All notable changes to `spatie/laravel-activitylog` will be documented in this file

## 3.17.0 - 2021-xx-xx

- drop PHP 7.2 support - [#855](https://github.com/spatie/laravel-activitylog/pull/855)

## 3.16.1 - 2020-11-03

- add PHP8 support - [#806](https://github.com/spatie/laravel-activitylog/pull/806)
- add PHP 8.0 support - [#806](https://github.com/spatie/laravel-activitylog/pull/806)

## 3.16.0 - 2020-09-16

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
}
],
"require": {
"php": "^7.2 || ^8.0",
"php": "^7.3 || ^8.0",
"illuminate/config": "^6.0 || ^7.0 || ^8.0",
"illuminate/database": "^6.0 || ^7.0 || ^8.0",
"illuminate/support": "^6.0 || ^7.0 || ^8.0"
},
"require-dev": {
"ext-json": "*",
"orchestra/testbench": "^4.0 || ^5.0 || ^6.0",
"phpunit/phpunit": "^8.0 || ^9.0"
"phpunit/phpunit": "^9.3"
},
"config": {
"sort-packages": true
Expand Down
12 changes: 7 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
Expand All @@ -14,9 +16,9 @@
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<coverage>
<include>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
</include>
</coverage>
</phpunit>
12 changes: 2 additions & 10 deletions tests/ActivityLoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,15 @@ public function it_can_translate_a_given_causer_id_to_an_object()
$this->assertEquals($userId, $firstActivity->causer->id);
}

/**
* @test
*
* @requires !Travis
*/
/** @test */
public function it_will_throw_an_exception_if_it_cannot_translate_a_causer_id()
{
$this->expectException(CouldNotLogActivity::class);

activity()->causedBy(999);
}

/**
* @test
*
* @requires !Travis
*/
/** @test */
public function it_will_use_the_logged_in_user_as_the_causer_by_default()
{
$userId = 1;
Expand Down
6 changes: 1 addition & 5 deletions tests/LogsActivityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,7 @@ public function it_can_log_activity_to_log_named_in_the_model()
$this->assertSame('custom_log', Activity::latest()->first()->log_name);
}

/**
* @test
*
* @requires !Travis
*/
/** @test */
public function it_will_not_log_an_update_of_the_model_if_only_ignored_attributes_are_changed()
{
$articleClass = new class() extends Article {
Expand Down
12 changes: 0 additions & 12 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use CreateActivityLogTable;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Encryption\Encrypter;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Schema;
use Orchestra\Testbench\TestCase as OrchestraTestCase;
Expand All @@ -18,22 +17,11 @@ abstract class TestCase extends OrchestraTestCase
{
public function setUp(): void
{
$this->checkCustomRequirements();

parent::setUp();

$this->setUpDatabase();
}

protected function checkCustomRequirements()
{
collect($this->getAnnotations())->filter(function ($location) {
return in_array('!Travis', Arr::get($location, 'requires', []));
})->each(function ($location) {
getenv('TRAVIS') && $this->markTestSkipped('Travis will not run this test.');
});
}

protected function getPackageProviders($app)
{
return [
Expand Down

0 comments on commit 5b49512

Please sign in to comment.