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
32 changes: 19 additions & 13 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
name: run-tests

on:
- push
on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest

strategy:
fail-fast: false
fail-fast: true
matrix:
php: [8.3, 8.2]
laravel: ['10.*', '11.*', '12.*']
dependency-version: [prefer-lowest, prefer-stable]
php: [8.5, 8.4, 8.3, 8.2]
laravel: ['13.*', '12.*', '11.*', '10.*']
stability: [prefer-stable]
include:
- laravel: 10.*
testbench: 8.*
- laravel: 11.*
testbench: 9.*
- laravel: 13.*
testbench: 11.*
- laravel: 12.*
testbench: 10.*
- laravel: 11.*
testbench: 9.*
- laravel: 10.*
testbench: 8.*
exclude:
- laravel: 13.*
php: 8.2
- laravel: 10.*
php: 8.5

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

steps:
- name: Checkout code
Expand All @@ -36,8 +42,8 @@ jobs:

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "nesbot/carbon:^2.63" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction

- name: Execute tests
run: vendor/bin/pest
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
],
"require": {
"php": "^8.2",
"illuminate/http": "^10.0|^11.0|^12.0",
"illuminate/support": "^10.0|^11.0|^12.0"
"illuminate/http": "^10.0|^11.0|^12.0|^13.0",
"illuminate/support": "^10.0|^11.0|^12.0|^13.0"
},
"require-dev": {
"mockery/mockery": "^1.3",
"orchestra/testbench": "^8.0|^9.0|^10.0",
"pestphp/pest": "^2.34|^3.7"
"orchestra/testbench": "^8.0|^9.0|^10.0|^11.0",
"pestphp/pest": "^2.34|^3.7|^4.0"
},
"autoload": {
"psr-4": {
Expand Down
21 changes: 7 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
</report>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="vendor/autoload.php"
backupGlobals="false"
colors="true"
processIsolation="false"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd">
<testsuites>
<testsuite name="Spatie Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
</phpunit>
14 changes: 10 additions & 4 deletions src/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use DateTimeImmutable;
use Exception;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Illuminate\Support\HtmlString;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -36,11 +37,14 @@ class Html
public const HTML_DATE_FORMAT = 'Y-m-d';
public const HTML_TIME_FORMAT = 'H:i:s';

protected ?Request $request;

/** @var \ArrayAccess|array */
protected $model;

public function __construct()
public function __construct(?Request $request = null)
{
$this->request = $request;
}

/**
Expand Down Expand Up @@ -533,7 +537,7 @@ public function token()
return $this
->hidden()
->name('_token')
->value(session()->token());
->value(($this->request ?? request())->session()->token());
}

/**
Expand Down Expand Up @@ -600,13 +604,15 @@ protected function old($name, $value = null)
// If there's no default value provided, the html builder currently
// has a model assigned and there aren't old input items,
// try to retrieve a value from the model.
if (is_null($value) && $this->model && empty(request()->old())) {
$request = $this->request ?? request();

if (is_null($value) && $this->model && empty($request->old())) {
$value = ($value = data_get($this->model, $name)) instanceof UnitEnum
? $this->getEnumValue($value)
: $value;
}

return request()->old($name, $value);
return $request->old($name, $value);
}

/**
Expand Down