Skip to content

Commit

Permalink
Merge pull request #80 from julienarcin/master
Browse files Browse the repository at this point in the history
 Add compatibility with Laravel 11
  • Loading branch information
kyranb authored Jul 24, 2024
2 parents 27f2453 + e50ad8f commit 952c722
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 135 deletions.
102 changes: 58 additions & 44 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,67 @@
name: run-tests

on: [push, pull_request]
on: [ push, pull_request ]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.1, 8.0, 7.4]
laravel: [7.*, 8.*, 9.*, 10.*]
dependency-version: [prefer-stable]
include:
- laravel: 10.*
testbench: 8.*
- laravel: 9.*
testbench: 7.*
- laravel: 8.*
testbench: 6.*
- laravel: 7.*
testbench: 5.*
exclude:
- laravel: 7.*
php: 8.1
- laravel: 9.*
php: 7.4
- laravel: 10.*
php: 7.4
- laravel: 10.*
php: 8.0
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ ubuntu-latest ]
php: [ 8.3, 8.2, 8.1, 8.0, 7.4 ]
laravel: [ 7.*, 8.*, 9.*, 10.*, 11.* ]
dependency-version: [ prefer-stable ]
include:
- laravel: 11.*
testbench: 9.*
- laravel: 10.*
testbench: 8.*
- laravel: 9.*
testbench: 7.*
- laravel: 8.*
testbench: 6.*
- laravel: 7.*
testbench: 5.*
exclude:
- laravel: 7.*
php: 8.1
- laravel: 7.*
php: 8.2
- laravel: 7.*
php: 8.3
- laravel: 8.*
php: 8.3
- laravel: 9.*
php: 7.4
- laravel: 10.*
php: 7.4
- laravel: 10.*
php: 8.0
- laravel: 11.*
php: 7.4
- laravel: 11.*
php: 8.0
- laravel: 11.*
php: 8.1

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

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

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

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --dev --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --dev --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
- name: Execute tests
run: vendor/bin/phpunit
- name: Execute tests
run: vendor/bin/phpunit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/node_modules
/vendor
.php_cs.cache
.phpunit.cache
.phpunit.result.cache
.DS_Store
Thumbs.db
Expand Down
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ php:
- 7.0
- 8.0
- 8.1
- 8.2
- 8.3
- hhvm

sudo: false
Expand Down
103 changes: 50 additions & 53 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,55 +1,52 @@
{
"name": "kyranb/footprints",
"type": "library",
"description": "A simple registration attribution tracking solution for Laravel (UTM Parameters and Referrers)",
"keywords": [
"footprints",
"tracking",
"utm",
"utm parameters",
"user tracking",
"attribution tracking"
],
"homepage": "https://github.com/kyranb/footprints",
"license": "MIT",
"authors": [
{
"name": "Kyran",
"email": "[email protected]"
}
],
"require": {
"php": "^7.4 || ^8.0 || ^8.1",
"illuminate/support": "^7.0 || ^8.0 || ^9.0 || ^10.0"
},
"require-dev": {
"orchestra/testbench": "^6.0",
"phpunit/phpunit": "^9.0"
},
"suggest": {
"jaybizzle/crawler-detect": "Needed if you plan to disable robots tracking"
},
"autoload": {
"psr-4": {
"Kyranb\\Footprints\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Kyranb\\Footprints\\Tests\\": "tests/"
}
},
"scripts": {
"test": "phpunit"
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
},
"laravel": {
"providers": [
"Kyranb\\Footprints\\FootprintsServiceProvider"
]
}
"name": "kyranb/footprints",
"type": "library",
"description": "A simple registration attribution tracking solution for Laravel (UTM Parameters and Referrers)",
"keywords": [
"footprints",
"tracking",
"utm",
"utm parameters",
"user tracking",
"attribution tracking"
],
"homepage": "https://github.com/kyranb/footprints",
"license": "MIT",
"authors": [
{
"name": "Kyran Beasley",
"email": "[email protected]"
}
}
],
"require": {
"php": "^7.4 || ^8.0",
"illuminate/support": "^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0"
},
"require-dev": {
"orchestra/testbench": "^6.0 || ^7.0 || ^8.0 || ^9.0",
"phpunit/phpunit": "^9.0 || ^10.0"
},
"suggest": {
"jaybizzle/crawler-detect": "Needed if you plan to disable robots tracking"
},
"autoload": {
"psr-4": {
"Kyranb\\Footprints\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Kyranb\\Footprints\\Tests\\": "tests/"
}
},
"scripts": {
"test": "phpunit"
},
"extra": {
"laravel": {
"providers": [
"Kyranb\\Footprints\\FootprintsServiceProvider"
]
}
}
}
60 changes: 26 additions & 34 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,36 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
verbose="true"
>
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<php>
<env name="APP_ENV" value="testing"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<php>
<env name="APP_ENV" value="testing"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
</php>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion src/TrackingLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ protected function captureReferrer()

$referrer['referrer_url'] = $this->request->headers->get('referer');

$parsedUrl = parse_url($referrer['referrer_url']);
$parsedUrl = parse_url($referrer['referrer_url'] ?? '');

$referrer['referrer_domain'] = isset($parsedUrl['host']) ? $parsedUrl['host'] : null;

Expand Down
3 changes: 0 additions & 3 deletions tests/Unit/Jobs/AssignPreviousVisitsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Kyranb\Footprints\Tests\Unit\Jobs;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Event;
use Kyranb\Footprints\Events\RegistrationTracked;
use Kyranb\Footprints\Jobs\AssignPreviousVisits;
Expand All @@ -12,8 +11,6 @@

class AssignPreviousVisitsTest extends TestCase
{
use RefreshDatabase;

public function test_emits_registration_tracked_event()
{
$trackable = $this->mock(TrackableInterface::class, function (MockInterface $mock) {
Expand Down

0 comments on commit 952c722

Please sign in to comment.