testinmg
This commit is contained in:
parent
91bbf06126
commit
069aaacf11
9 changed files with 411 additions and 64 deletions
|
@ -16,6 +16,7 @@
|
|||
"laravel/sail": "^1.0.1",
|
||||
"mockery/mockery": "^1.4.4",
|
||||
"nunomaduro/collision": "^6.1",
|
||||
"pestphp/pest-plugin-laravel": "^1.2",
|
||||
"phpunit/phpunit": "^9.5.10",
|
||||
"spatie/laravel-ignition": "^1.0"
|
||||
},
|
||||
|
@ -57,7 +58,10 @@
|
|||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"pestphp/pest-plugin": true
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
|
|
257
composer.lock
generated
257
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "12524947d8c752f84bc21aaaede06bfa",
|
||||
"content-hash": "cb04fd9a53709c6f2ef827bfaf387e82",
|
||||
"packages": [
|
||||
{
|
||||
"name": "brick/math",
|
||||
|
@ -5672,6 +5672,261 @@
|
|||
],
|
||||
"time": "2022-04-05T15:31:38+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pestphp/pest",
|
||||
"version": "v1.21.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pestphp/pest.git",
|
||||
"reference": "63f009fadf9b37f611fda43928d03336475d5d9f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pestphp/pest/zipball/63f009fadf9b37f611fda43928d03336475d5d9f",
|
||||
"reference": "63f009fadf9b37f611fda43928d03336475d5d9f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"nunomaduro/collision": "^5.10.0|^6.0",
|
||||
"pestphp/pest-plugin": "^1.0.0",
|
||||
"php": "^7.3 || ^8.0",
|
||||
"phpunit/phpunit": "^9.5.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"illuminate/console": "^8.47.0",
|
||||
"illuminate/support": "^8.47.0",
|
||||
"laravel/dusk": "^6.15.0",
|
||||
"pestphp/pest-dev-tools": "dev-master",
|
||||
"pestphp/pest-plugin-parallel": "^1.0"
|
||||
},
|
||||
"bin": [
|
||||
"bin/pest"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
},
|
||||
"pest": {
|
||||
"plugins": [
|
||||
"Pest\\Plugins\\Coverage",
|
||||
"Pest\\Plugins\\Init",
|
||||
"Pest\\Plugins\\Version",
|
||||
"Pest\\Plugins\\Environment"
|
||||
]
|
||||
},
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Pest\\Laravel\\PestServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/Functions.php",
|
||||
"src/Pest.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Pest\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nuno Maduro",
|
||||
"email": "enunomaduro@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "An elegant PHP Testing Framework.",
|
||||
"keywords": [
|
||||
"framework",
|
||||
"pest",
|
||||
"php",
|
||||
"test",
|
||||
"testing",
|
||||
"unit"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/pestphp/pest/issues",
|
||||
"source": "https://github.com/pestphp/pest/tree/v1.21.2"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://www.paypal.com/paypalme/enunomaduro",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/lukeraymonddowning",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/nunomaduro",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/octoper",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/olivernybroe",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/owenvoke",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://www.patreon.com/nunomaduro",
|
||||
"type": "patreon"
|
||||
}
|
||||
],
|
||||
"time": "2022-03-05T19:34:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pestphp/pest-plugin",
|
||||
"version": "v1.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pestphp/pest-plugin.git",
|
||||
"reference": "fc8519de148699fe612d9c669be60554cd2db4fa"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pestphp/pest-plugin/zipball/fc8519de148699fe612d9c669be60554cd2db4fa",
|
||||
"reference": "fc8519de148699fe612d9c669be60554cd2db4fa",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"composer-plugin-api": "^1.1 || ^2.0",
|
||||
"php": "^7.3 || ^8.0"
|
||||
},
|
||||
"conflict": {
|
||||
"pestphp/pest": "<1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"composer/composer": "^1.10.19",
|
||||
"pestphp/pest": "^1.0",
|
||||
"pestphp/pest-dev-tools": "dev-master"
|
||||
},
|
||||
"type": "composer-plugin",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
},
|
||||
"class": "Pest\\Plugin\\Manager"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Pest\\Plugin\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "The Pest plugin manager",
|
||||
"keywords": [
|
||||
"framework",
|
||||
"manager",
|
||||
"pest",
|
||||
"php",
|
||||
"plugin",
|
||||
"test",
|
||||
"testing",
|
||||
"unit"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/pestphp/pest-plugin/tree/v1.0.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/nunomaduro",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://www.patreon.com/nunomaduro",
|
||||
"type": "patreon"
|
||||
}
|
||||
],
|
||||
"time": "2021-01-03T15:53:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pestphp/pest-plugin-laravel",
|
||||
"version": "v1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pestphp/pest-plugin-laravel.git",
|
||||
"reference": "64996218006570f6f58f3c7ebb6f0c7bfb3c60b9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pestphp/pest-plugin-laravel/zipball/64996218006570f6f58f3c7ebb6f0c7bfb3c60b9",
|
||||
"reference": "64996218006570f6f58f3c7ebb6f0c7bfb3c60b9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"laravel/framework": "^7.0 || ^8.0 || ^9.0",
|
||||
"pestphp/pest": "^1.7",
|
||||
"php": "^7.3 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"orchestra/testbench": "^5.12.1 || ^6.7.2",
|
||||
"pestphp/pest-dev-tools": "dev-master"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/Autoload.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Pest\\Laravel\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "The Pest Laravel Plugin",
|
||||
"keywords": [
|
||||
"framework",
|
||||
"laravel",
|
||||
"pest",
|
||||
"php",
|
||||
"test",
|
||||
"testing",
|
||||
"unit"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/pestphp/pest-plugin-laravel/tree/v1.2.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://www.paypal.com/paypalme/enunomaduro",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/nunomaduro",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://www.patreon.com/nunomaduro",
|
||||
"type": "patreon"
|
||||
}
|
||||
],
|
||||
"time": "2022-01-13T17:09:04+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phar-io/manifest",
|
||||
"version": "2.0.3",
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
@section('content')
|
||||
|
||||
<form action="{{ route('joined.store') }}" method="POST" enctype="multipart/form-data"
|
||||
<form action="{{ route('admin.joined.store') }}" method="POST" enctype="multipart/form-data"
|
||||
autocomplete="off">
|
||||
@csrf
|
||||
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_the_application_returns_a_successful_response()
|
||||
{
|
||||
$response = $this->get('/');
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SessionsControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic feature test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_example()
|
||||
{
|
||||
$response = $this->get('/');
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
90
tests/Feature/JoinedTest.php
Normal file
90
tests/Feature/JoinedTest.php
Normal file
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Collective;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
beforeEach(function () {
|
||||
$this->user = Collective::first();
|
||||
});
|
||||
|
||||
test('get joined index', function () {
|
||||
$response = $this->actingAs($this->user)->get('fanatic/joined');
|
||||
$response->assertViewIs('admin.joined.index');
|
||||
});
|
||||
|
||||
test('get joined create', function () {
|
||||
$response = $this->actingAs($this->user)->get('fanatic/joined/create');
|
||||
$response->assertViewIs('admin.joined.create');
|
||||
});
|
||||
|
||||
test('valid joined form passes create validation', function () {
|
||||
$response = $this->actingAs($this->user)->post('/fanatic/joined', [
|
||||
'categories' => [3, 10],
|
||||
'url' => 'http://punkfairie.net',
|
||||
'subject' => 'Test',
|
||||
]);
|
||||
|
||||
$response->assertValid();
|
||||
});
|
||||
|
||||
test('invalid category response does not pass create validation', function () {
|
||||
$response = $this->actingAs($this->user)->post('/fanatic/joined', [
|
||||
'categories' => 4,
|
||||
'url' => 'http://punkfairie.net',
|
||||
'subject' => 'Test',
|
||||
]);
|
||||
|
||||
$response->assertInvalid();
|
||||
});
|
||||
|
||||
test('invalid url does not pass create validation', function () {
|
||||
$response = $this->actingAs($this->user)->post('/fanatic/joined', [
|
||||
'categories' => [4],
|
||||
'url' => 'hello',
|
||||
'subject' => 'Test',
|
||||
]);
|
||||
|
||||
$response->assertInvalid();
|
||||
});
|
||||
|
||||
test('missing category does not pass create validation', function () {
|
||||
$response = $this->actingAs($this->user)->post('/fanatic/joined', [
|
||||
'url' => 'https://punkfairie.net',
|
||||
'subject' => 'Test',
|
||||
]);
|
||||
|
||||
$response->assertInvalid();
|
||||
});
|
||||
|
||||
test('missing subject does not pass create validation', function () {
|
||||
$response = $this->actingAs($this->user)->post('/fanatic/joined', [
|
||||
'categories' => [1,5],
|
||||
'url' => 'https://punkfairie.net',
|
||||
]);
|
||||
|
||||
$response->assertInvalid();
|
||||
});
|
||||
|
||||
test('missing url does not pass create validation', function () {
|
||||
$response = $this->actingAs($this->user)->post('/fanatic/joined', [
|
||||
'categories' => [2],
|
||||
'subject' => 'Test',
|
||||
]);
|
||||
|
||||
$response->assertInvalid();
|
||||
});
|
||||
|
||||
// test('can upload joined button on create', function () {
|
||||
// Storage::fake('local');
|
||||
// $file = UploadedFile::fake()->image('code.png');
|
||||
|
||||
// $response = $this->actingAs($this->user)->post('/fanatic/joined', [
|
||||
// 'categories' => [3, 10],
|
||||
// 'url' => 'http://punkfairie.net',
|
||||
// 'subject' => 'Test',
|
||||
// 'image' => $file,
|
||||
// ]);
|
||||
|
||||
// Storage::disk('local')->assertExists($file->hashName());
|
||||
// });
|
14
tests/Feature/SessionsTest.php
Normal file
14
tests/Feature/SessionsTest.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Collective;
|
||||
|
||||
test('dashboard hidden for guests', function () {
|
||||
$response = $this->get('/fanatic');
|
||||
$response->assertRedirect('/fanatic/login');
|
||||
});
|
||||
|
||||
test('logs in', function () {
|
||||
$user = Collective::first();
|
||||
$response = $this->actingAs($user)->get('/fanatic');
|
||||
$response->assertViewIs('admin.dashboard');
|
||||
});
|
45
tests/Pest.php
Normal file
45
tests/Pest.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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 "uses()" function to bind a different classes or traits.
|
||||
|
|
||||
*/
|
||||
|
||||
uses(Tests\TestCase::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()
|
||||
{
|
||||
// ..
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_that_true_is_true()
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue