mirror of https://github.com/4xmen/xshop.git
Merge remote-tracking branch 'origin/master'
commit
bdf3ef01a2
@ -0,0 +1,54 @@
|
||||
name: Laravel
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
pull_request:
|
||||
branches: [ "master" ]
|
||||
|
||||
jobs:
|
||||
laravel-tests:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
|
||||
with:
|
||||
php-version: '8.2'
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '18'
|
||||
- name: Copy .env
|
||||
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
|
||||
- name: remove composer lock
|
||||
run: rm composer.lock
|
||||
- name: Install Dependencies
|
||||
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --ignore-platform-reqs
|
||||
- name: Generate key
|
||||
run: php artisan key:generate
|
||||
- name: Directory Permissions
|
||||
run: chmod -R 777 storage bootstrap/cache
|
||||
- name: Create Database
|
||||
run: |
|
||||
mkdir -p database
|
||||
touch database/database.sqlite
|
||||
- name: Dataseeder
|
||||
env:
|
||||
DB_CONNECTION: sqlite
|
||||
DB_DATABASE: database/database.sqlite
|
||||
run: php artisan migrate --seed
|
||||
- name: Npm install
|
||||
run: npm install
|
||||
- name: client build
|
||||
env:
|
||||
DB_CONNECTION: sqlite
|
||||
DB_DATABASE: database/database.sqlite
|
||||
run: php artisan client
|
||||
- name: npm build
|
||||
run: npm run build
|
||||
- name: Execute tests (Unit and Feature tests) via PHPUnit
|
||||
env:
|
||||
DB_CONNECTION: sqlite
|
||||
DB_DATABASE: database/database.sqlite
|
||||
run: php artisan test
|
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\Group;
|
||||
use App\Models\Post;
|
||||
use App\Models\Product;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ClientWebPagesTest extends TestCase
|
||||
{
|
||||
|
||||
public function test_web_client_index(): void
|
||||
{
|
||||
$response = $this->get(route('client.welcome'));
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
public function test_web_client_posts(): void
|
||||
{
|
||||
$response = $this->get(route('client.posts'));
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
public function test_web_client_products(): void
|
||||
{
|
||||
$response = $this->get(route('client.products'));
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
public function test_web_client_product(): void
|
||||
{
|
||||
|
||||
if (Product::count() == 0) {
|
||||
Product::factory(1)->create();
|
||||
}
|
||||
$response = $this->get(Product::first()->webUrl());
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
public function test_web_client_post(): void
|
||||
{
|
||||
|
||||
if (Post::count() == 0) {
|
||||
Post::factory(1)->create();
|
||||
}
|
||||
$response = $this->get(Post::first()->webUrl());
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
public function test_web_client_group(): void
|
||||
{
|
||||
|
||||
if (Group::count() == 0) {
|
||||
Group::factory(1)->create();
|
||||
}
|
||||
$response = $this->get(Group::first()->webUrl());
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
public function test_web_client_category(): void
|
||||
{
|
||||
|
||||
if (Category::count() == 0) {
|
||||
Category::factory(1)->create();
|
||||
}
|
||||
$response = $this->get(Category::first()->webUrl());
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class CustomerTest extends TestCase
|
||||
{
|
||||
|
||||
public function check(){
|
||||
if (Customer::count() == 0){
|
||||
Customer::factory(1)->create();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A basic feature test example.
|
||||
*/
|
||||
public function test_customer_profile(): void
|
||||
{
|
||||
|
||||
$this->check();
|
||||
$response = $this->actingAs(Customer::inRandomOrder()->first(),'customer')->get(route('client.profile'));
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SiteMapTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic feature test example.
|
||||
*/
|
||||
public function test_sitemap(): void
|
||||
{
|
||||
$response = $this->get(route('sitemap'));
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue