Skip to content

Commit

Permalink
Laravel 10 support (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMuller authored Mar 1, 2023
1 parent acc41f2 commit 95cfdd1
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 67 deletions.
23 changes: 11 additions & 12 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,26 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: [7.4, 8.0]
laravel: [^7.2, ^8.0, ^9.0]
php: [8.0, 8.1, 8.2]
laravel: [9.*, 10.*]
dependency-version: [prefer-lowest, prefer-stable]
include:
- laravel: ^9.0
testbench: 7.*
- laravel: ^8.0
testbench: 6.*
- laravel: ^7.2
testbench: 5.*
- laravel: 9.*
testbench: 7.*
- laravel: 10.*
testbench: 8.*
exclude:
- laravel: ^9.0
php: 7.4
- laravel: 10.*
php: 8.0

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

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

- name: Cache dependencies
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.composer/cache/files
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
Expand All @@ -42,6 +40,7 @@ jobs:
php-version: ${{ matrix.php }}
extensions: json
coverage: none
tools: composer:v2

- name: Install dependencies
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ vendor
coverage
.idea
.phpunit.result.cache
.phpunit.cache/test-results
.DS_STORE
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to `laravel-js-store` will be documented in this file

## 3.0.0 - 2023-03-01
- Add support for Laravel 10
- Add support for PHP 8.2
- Drop support for Laravel 7 and 8
- Drop support for PHP 7.4

## 2.1.0 - 2022-08-07
- Add support for Laravel 9

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You can also manually push data on the fly, for example in a controller.
You can install the package via composer:

```bash
composer require hihaho/laravel-js-store:^1.0
composer require hihaho/laravel-js-store:^3.0
```

Next you should render the js data on your page, there are a few different ways to do this:
Expand Down Expand Up @@ -146,7 +146,7 @@ This package registers a singleton to manage all data that's sent to the JS Stor
Laravel Octane will register one instance per request, but only when the singleton is not accessed inside a service provider.
For this reason it's not possible to push data to the store within a service provider.

Generally it won't be nesecarry to flush all data between requests, but if you need this behaviour you can flush the data between requests.
Generally it won't be necessary to flush all data between requests, but if you need this behaviour you can flush the data between requests.
Any data that is pushed within a service provider won't be available in requests.
To flush the data between requests you should add the `PrepareStoreForNextOperation::class` listener to the following Octane events in `config/octane.php`:
- `RequestReceived::class`
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
}
],
"require": {
"php": "^7.4|^8.0",
"php": "^8.0",
"ext-json": "*",
"illuminate/support": "^7.2|^8.0|^9.0",
"spatie/laravel-package-tools": "^1.1"
"illuminate/support": "^9.34|^10.0",
"spatie/laravel-package-tools": "^1.14"
},
"require-dev": {
"orchestra/testbench": "^5.0|^6.0|^7.0",
"phpunit/phpunit": "^8.0|^9.0",
"orchestra/testbench": "^7.9|^8.0",
"phpunit/phpunit": "^9.2|^10.0",
"squizlabs/php_codesniffer": "^3.4"
},
"autoload": {
Expand Down
21 changes: 4 additions & 17 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
<?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/10.0/phpunit.xsd"
bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
backupStaticProperties="false">
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@ public function test_it_creates_a_data_provider(): void

$this->assertFalse(File::exists($provider));

$command = $this->artisan('make:frontend-data-provider', ['name' => 'Test'])
->expectsConfirmation("Generated key: $key, would you like to use a custom key?")
->assertExitCode(0);

if (method_exists($command, 'expectsOutputToContain')) {
$command->expectsOutputToContain('FrontendDataProvider created successfully.');
} else {
$command->expectsOutput('FrontendDataProvider created successfully.');
}
$expectedOutput = version_compare($this->app->version(), '9.32.0', '>=')
? 'FrontendDataProvider [app/Http/FrontendDataProviders/Test.php] created successfully.'
: 'FrontendDataProvider created successfully.';

$command->run();
$this->artisan('make:frontend-data-provider', ['name' => 'Test'])
->expectsOutputToContain($expectedOutput)
->expectsConfirmation("Generated key: $key, would you like to use a custom key?")
->assertExitCode(0)
->run();

$this->assertTrue(File::exists($provider));

Expand Down Expand Up @@ -71,18 +69,16 @@ public function test_it_should_set_key_when_custom_key_is_empty(): void

$this->assertFalse(File::exists($provider));

$command = $this->artisan('make:frontend-data-provider', ['name' => 'Test'])
$expectedOutput = version_compare($this->app->version(), '9.32.0', '>=')
? 'FrontendDataProvider [app/Http/FrontendDataProviders/Test.php] created successfully.'
: 'FrontendDataProvider created successfully.';

$this->artisan('make:frontend-data-provider', ['name' => 'Test'])
->expectsOutputToContain($expectedOutput)
->expectsConfirmation("Generated key: $key, would you like to use a custom key?", 'yes')
->expectsQuestion('Custom key', '')
->assertExitCode(0);

if (method_exists($command, 'expectsOutputToContain')) {
$command->expectsOutputToContain('FrontendDataProvider created successfully.');
} else {
$command->expectsOutput('FrontendDataProvider created successfully.');
}

$command->run();
->assertExitCode(0)
->run();

$this->assertTrue(File::exists($provider));

Expand All @@ -109,7 +105,7 @@ public function data()
}
CLASS;

$this->assertSame($expectedContents, file_get_contents($provider));
}

Expand All @@ -125,18 +121,16 @@ public function test_it_creates_a_data_provider_with_custom_key(): void

$this->assertFalse(File::exists($provider));

$command = $this->artisan('make:frontend-data-provider', ['name' => 'Test'])
$expectedOutput = version_compare($this->app->version(), '9.32.0', '>=')
? 'FrontendDataProvider [app/Http/FrontendDataProviders/Test.php] created successfully.'
: 'FrontendDataProvider created successfully.';

$this->artisan('make:frontend-data-provider', ['name' => 'Test'])
->expectsOutputToContain($expectedOutput)
->expectsConfirmation("Generated key: $key, would you like to use a custom key?", 'yes')
->expectsQuestion('Custom key', 'custom-key')
->assertExitCode(0);

if (method_exists($command, 'expectsOutputToContain')) {
$command->expectsOutputToContain('FrontendDataProvider created successfully.');
} else {
$command->expectsOutput('FrontendDataProvider created successfully.');
}

$command->run();
->assertExitCode(0)
->run();

$this->assertTrue(File::exists($provider));

Expand Down

0 comments on commit 95cfdd1

Please sign in to comment.