Merge pull request #13 from 4xmen/master

Update system test
pull/16/head
A1Gard 2 years ago committed by GitHub
commit 5906b29f03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -122,7 +122,7 @@ crontab -e
```bash
* * * * * cd /home/[yourusername]/[your-public-html-project-root] && php artisan schedule:run >> /dev/null 2>&1
```
## contribute & support
## همکاری و پشتیبانی
ما خیلی خوشحال می‌شویم از شما را کمک کنیم و یا شما ما رو کمک کنید، در صورت توسعه سورس حتما از pull request شما اتسقبال می‌کنیم و اگر مشکلی داشتید، حتما آن را برطرف می‌کنیم، فقط کافی است یک موضوع در لینک زیر ایجاد کنید:
@ -130,6 +130,16 @@ crontab -e
https://github.com/4xmen/xshop/issues
```
## تست پروژه
نکته: تست را حتماً برای نسخه توسعه استفاده کنید نه روی وبسایت زیر بار دستور تست از قرار ذیل است:
```bash
php artisan test
```
## Screen shots
![1](./media/shopscreenshot1.png)

@ -89,7 +89,7 @@ php artisan serv
now login to admin panel `http://localhost:8000/dashboard` default admin email is : `admin@example.com` and default password is: `password`
# Deploy guide
## Deploy guide
We recommend deploy xshop on VPS, so create databse and run this commands
@ -108,7 +108,7 @@ php key:generate
composer install --optimize-autoloader --no-dev
```
### add cron job
### Add cron job
You must add crontab for your project:
@ -121,7 +121,7 @@ Add this line:
* * * * * cd /home/[yourusername]/[your-public-html-project-root] && php artisan schedule:run >> /dev/null 2>&1
```
## contribute & support
## Contribute & support
We are so pleased to your help and help you, If you wanna develop xshop, Congrats or
if you have problem, don't worry create an issue here:
@ -130,6 +130,14 @@ if you have problem, don't worry create an issue here:
https://github.com/4xmen/xshop/issues
```
## Test
Note: The test must be run on development version, and test command is:
```bash
php artisan test
```
## Screen shots
![1](./media/shopscreenshot1.png)

@ -29,9 +29,9 @@
</label>
<select name="customer_id" data-live-search="true" id="customer_id"
class="form-control searchable @error('customer_id') is-invalid @enderror">
@foreach(\App\models\Customer::all() as $customer )
@foreach(\App\Models\Customer::all() as $customer )
<option value="{{ $customer->id }}"
@if (old('customer_id',$invoice->customer_id??null) == $customer->id ) selected @endif > {{$customer->name}} </option>
@if (old('customer_id',$invoice?->customer_id??null) == $customer->id ) selected @endif > {{$customer->name}} </option>
@endforeach
</select>
</div>
@ -76,43 +76,49 @@
value="{{old('tracking_code',$invoice->tracking_code??null)}}"/>
</div>
</div>
@foreach($invoice->products as $product )
@if(isset($invoice))
@foreach($invoice->products as $product )
<div class="col-md-6">
<div class="card">
<div id="product_{{$product->id}}" class="row">
<div class="col-md-6 mt-3">
<div class="form-group">
<label for="products">
{{__('Product')}}
</label>
<select data-live-search="true" name="products.ids[]" data-live-search="true" id="products"
class="form-control searchable">
@foreach(\App\models\Product::all() as $allProduct )
<option value="{{ $allProduct->id }}"
@if ($product->id==$allProduct->id ) selected @endif > {{$allProduct->name}} </option>
@endforeach
</select>
</div>
</div>
<div class="col-md-6 mt-3">
<div class="form-group">
<label for="count">
{{__('Count')}}
</label>
<input type="number" name="products.counts[]" value="{{$product->pivot->count}}"
id="" class="form-control">
<button class="btn btn-outline-danger "
onclick="document.getElementById('product_{{$product->id}}').remove()"> X
</button>
</div>
</div>
<div class="col-md-6">
<div class="card">
<div id="product_{{$product->id}}" class="row">
<div class="col-md-6 mt-3">
<div class="form-group">
<label for="products">
{{__('Product')}}
</label>
<select data-live-search="true" name="products.ids[]"
data-live-search="true" id="products"
class="form-control searchable">
@foreach(\App\models\Product::all() as $allProduct )
<option value="{{ $allProduct->id }}"
@if ($product->id==$allProduct->id ) selected @endif > {{$allProduct->name}} </option>
@endforeach
</select>
</div>
</div>
<div class="col-md-6 mt-3">
<div class="form-group">
<label for="count">
{{__('Count')}}
</label>
<input type="number" name="products.counts[]"
value="{{$product->pivot->count}}"
id="" class="form-control">
<button class="btn btn-outline-danger "
onclick="document.getElementById('product_{{$product->id}}').remove()">
X
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endforeach
@endif
@endforeach
<div class="col-md-12">
<label> &nbsp;</label>
<input name="" type="submit" class="btn btn-primary mt-2" value="{{__('Save')}}"/>

@ -0,0 +1,397 @@
<?php
namespace Tests\Feature;
use App\Models\Cat;
use App\Models\Contact;
use App\Models\Customer;
use App\Models\Discount;
use App\Models\Invoice;
use App\Models\Product;
use App\Models\Question;
use App\Models\Ticket;
use App\Models\Transport;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Spatie\Permission\Models\Role;
use Tests\TestCase;
use Xmen\StarterKit\Models\Adv;
use Xmen\StarterKit\Models\Category;
use Xmen\StarterKit\Models\Clip;
use Xmen\StarterKit\Models\Comment;
use Xmen\StarterKit\Models\Gallery;
use Xmen\StarterKit\Models\Menu;
use Xmen\StarterKit\Models\Poll;
use Xmen\StarterKit\Models\Post;
use Xmen\StarterKit\Models\Slider;
class AdminWebPagesTest extends TestCase
{
/**
* A basic feature test example.
*
* @return void
*/
public function test_user_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.user.all'));
$response->assertStatus(200);
$response = $this->actingAs($user)->get(route('admin.user.create'));
$response->assertStatus(200);
$response = $this->actingAs($user)->get(route('admin.user.edit',$user->id));
$response->assertStatus(200);
}
public function test_category_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.category.index'));
$response->assertStatus(200);
$response = $this->actingAs($user)->get(route('admin.category.create'));
$response->assertStatus(200);
if (Category::count() != 0){
$response = $this->actingAs($user)->get(route('admin.category.edit',Category::first()->slug));
$response->assertStatus(200);
}
}
public function test_post_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.post.index'));
$response->assertStatus(200);
$response = $this->actingAs($user)->get(route('admin.post.create'));
$response->assertStatus(200);
if (Post::count() != 0){
$response = $this->actingAs($user)->get(route('admin.post.edit',Post::first()->slug));
$response->assertStatus(200);
}
}
public function test_gallery_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.gallery.all'));
$response->assertStatus(200);
$response = $this->actingAs($user)->get(route('admin.gallery.create'));
$response->assertStatus(200);
if (Gallery::count() != 0){
$response = $this->actingAs($user)->get(route('admin.gallery.edit',Gallery::first()->slug));
$response->assertStatus(200);
}
}
public function test_adv_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.adv.index'));
$response->assertStatus(200);
$response = $this->actingAs($user)->get(route('admin.adv.create'));
$response->assertStatus(200);
if (Adv::count() != 0){
$response = $this->actingAs($user)->get(route('admin.adv.edit',Adv::first()->slug));
$response->assertStatus(200);
}
}
public function test_attachment_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.attachment.index'));
$response->assertStatus(200);
}
public function test_cat_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.cat.index'));
$response->assertStatus(200);
$response = $this->actingAs($user)->get(route('admin.cat.create'));
$response->assertStatus(200);
if (Cat::count() != 0){
$response = $this->actingAs($user)->get(route('admin.cat.edit',Cat::first()->slug));
$response->assertStatus(200);
}
}
public function test_clip_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.clip.index'));
$response->assertStatus(200);
$response = $this->actingAs($user)->get(route('admin.clip.create'));
$response->assertStatus(200);
if (Clip::count() != 0){
$response = $this->actingAs($user)->get(route('admin.clip.edit',Clip::first()->slug));
$response->assertStatus(200);
}
}
public function test_comment_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.comment.index'));
$response->assertStatus(200);
if (Comment::count() != 0){
$response = $this->actingAs($user)->get(route('admin.comment.edit',Comment::first()->id));
$response->assertStatus(200);
}
}
public function test_contact_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.contact.index'));
$response->assertStatus(200);
if (Contact::count() != 0){
$response = $this->actingAs($user)->get(route('admin.contact.reply',Contact::first()->id));
$response->assertStatus(200);
$response = $this->actingAs($user)->get(route('admin.contact.show',Contact::first()->id));
$response->assertStatus(200);
}
}
public function test_customer_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.customer.index'));
$response->assertStatus(200);
$response = $this->actingAs($user)->get(route('admin.customer.create'));
$response->assertStatus(200);
if (Customer::count() != 0){
$response = $this->actingAs($user)->get(route('admin.customer.edit',Customer::first()->slug));
$response->assertStatus(200);
}
}
public function test_discount_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.discount.index'));
$response->assertStatus(200);
$response = $this->actingAs($user)->get(route('admin.discount.create'));
$response->assertStatus(200);
if (Discount::count() != 0){
$response = $this->actingAs($user)->get(route('admin.discount.edit',Discount::first()->id));
$response->assertStatus(200);
}
}
public function test_question_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.question.index'));
$response->assertStatus(200);
if (Question::count() != 0){
$response = $this->actingAs($user)->get(route('admin.question.edit',Question::first()->id));
$response->assertStatus(200);
}
}
public function test_invoice_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.invoice.index'));
$response->assertStatus(200);
$response = $this->actingAs($user)->get(route('admin.invoice.create'));
$response->assertStatus(200);
if (Invoice::count() != 0){
$response = $this->actingAs($user)->get(route('admin.invoice.edit',Invoice::first()->id));
$response->assertStatus(200);
}
}
public function test_menu_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.menu.index'));
$response->assertStatus(200);
if (Menu::count() != 0){
$response = $this->actingAs($user)->get(route('admin.menu.manage',Menu::first()->id));
$response->assertStatus(200);
}
}
public function test_slider_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.slider.index'));
$response->assertStatus(200);
$response = $this->actingAs($user)->get(route('admin.slider.create'));
$response->assertStatus(200);
if (Slider::count() != 0){
$response = $this->actingAs($user)->get(route('admin.slider.edit',Slider::first()->id));
$response->assertStatus(200);
}
}
public function test_poll_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.poll.index'));
$response->assertStatus(200);
$response = $this->actingAs($user)->get(route('admin.poll.create'));
$response->assertStatus(200);
if (Poll::count() != 0){
$response = $this->actingAs($user)->get(route('admin.poll.edit',Poll::first()->id));
$response->assertStatus(200);
}
}
public function test_product_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.product.index'));
$response->assertStatus(200);
$response = $this->actingAs($user)->get(route('admin.product.create'));
$response->assertStatus(200);
if (Product::count() != 0){
$response = $this->actingAs($user)->get(route('admin.product.edit',Product::first()->slug));
$response->assertStatus(200);
}
}
public function test_ticket_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.ticket.index'));
$response->assertStatus(200);
// $response = $this->actingAs($user)->get(route('admin.ticket.create'));
// $response->assertStatus(200);
if (Ticket::count() != 0){
$response = $this->actingAs($user)->get(route('admin.ticket.edit',Ticket::first()->id));
$response->assertStatus(200);
}
}
public function test_transport_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.transport.index'));
$response->assertStatus(200);
$response = $this->actingAs($user)->get(route('admin.transport.create'));
$response->assertStatus(200);
if (Transport::count() != 0){
$response = $this->actingAs($user)->get(route('admin.transport.edit',Transport::first()->id));
$response->assertStatus(200);
}
}
public function test_setting_urls()
{
$user = $this->getValidUser();
$response = $this->actingAs($user)->get(route('admin.setting.index'));
$response->assertStatus(200);
}
private function getValidUser(){
if (User::where('email','admin@example.com')->count() == 0){
if (Role::where('name','super-admin')->count() == 0){
$role = Role::create(['name' => 'super-admin']);
}else{
$role = Role::where('name','super-admin')->first();
}
$user = User::factory()->count(1)->create(['email' => 'admin@example.com']);
$user->assignRole($role);
}else{
$user = User::where('email','admin@example.com')->first();
}
return $user;
}
}

@ -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,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…
Cancel
Save