laravel #1

Merged
toyrik merged 3 commits from laravel into master 2026-02-01 07:57:18 +03:00
6 changed files with 1394 additions and 360 deletions
Showing only changes of commit 0841ec51f9 - Show all commits

View File

@ -17,7 +17,8 @@
"laravel/sail": "^1.41",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.6",
"phpunit/phpunit": "^11.5.3"
"pestphp/pest": "^4.3",
"pestphp/pest-plugin-laravel": "^4.0"
},
"autoload": {
"psr-4": {
@ -44,10 +45,6 @@
"Composer\\Config::disableProcessTimeout",
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1 --timeout=0\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
],
"test": [
"@php artisan config:clear --ansi",
"@php artisan test"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
@ -71,6 +68,17 @@
],
"pint-fix": [
"@php vendor/bin/pint --repair"
],
"test": [
"@php artisan optimize:clear",
"@php vendor/bin/pest"
],
"checkit": [
"@pint-test",
"@test"
],
"ci": [
"@checkit"
]
},
"extra": {

1617
src/composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace Tests;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\App;
trait CreateApplication
{
public function createApplication(): Application
{
$app = require Application::inferBasePath() . '/bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
if (App::environment() !== 'testing') {
dump('You are not in a test environment!');
dump('Run "php artisan optimize:clear" before tests');
dd('and "php artizan optimize" after if you are in production');
}
return $app;
}
}

View File

@ -2,20 +2,8 @@
declare(strict_types=1);
namespace Tests\Feature;
// use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*/
public function test_the_application_returns_a_successful_response(): void
{
it('returns a successful response', function () {
$response = $this->get('/');
$response->assertStatus(200);
}
}
});

49
src/tests/Pest.php Normal file
View File

@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
/*
|--------------------------------------------------------------------------
| Test Case
|--------------------------------------------------------------------------
|
| The closure you provide to your test functions is always bound to a specific PHPUnit test
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
| need to change it using the "pest()" function to bind a different classes or traits.
|
*/
pest()->extend(Tests\TestCase::class)
// ->use(Illuminate\Foundation\Testing\RefreshDatabase::class)
->in('Feature');
/*
|--------------------------------------------------------------------------
| Expectations
|--------------------------------------------------------------------------
|
| When you're writing tests, you often need to check that values meet certain conditions. The
| "expect()" function gives you access to a set of "expectations" methods that you can use
| to assert different things. Of course, you may extend the Expectation API at any time.
|
*/
expect()->extend('toBeOne', function () {
return $this->toBe(1);
});
/*
|--------------------------------------------------------------------------
| Functions
|--------------------------------------------------------------------------
|
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
| project that you don't want to repeat in every file. Here you can also expose helpers as
| global functions to help you to reduce the number of lines of code in your test files.
|
*/
function something()
{
// ..
}

View File

@ -2,17 +2,6 @@
declare(strict_types=1);
namespace Tests\Unit;
use PHPUnit\Framework\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*/
public function test_that_true_is_true(): void
{
$this->assertTrue(true);
}
}
test('that true is true', function () {
expect(true)->toBeTrue();
});