Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/mcoil.corals.io/tests/Feature/Admin/Customers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/mcoil.corals.io/tests/Feature/Admin/Customers/CustomersFeatureTest.php
<?php

namespace Tests\Feature\Admin\Customers;

use App\Shop\Addresses\Address;
use App\Shop\Cities\City;
use App\Shop\Countries\Country;
use App\Shop\Customers\Customer;
use App\Shop\Customers\Repositories\CustomerRepository;
use App\Shop\Provinces\Province;
use Illuminate\Support\Str;
use Tests\TestCase;

class CustomersFeatureTest extends TestCase
{
    /** @test */
    public function it_can_edit_the_customer_address()
    {
        factory(Country::class)->create();
        factory(Province::class)->create();
        factory(City::class)->create();
        $customer = factory(Customer::class)->create();
        $address = factory(Address::class)->create();

        $customerRepo = new CustomerRepository($customer);
        $attachedAddress = $customerRepo->attachAddress($address);

        $this
            ->actingAs($this->employee, 'employee')
            ->get(route('admin.customers.addresses.edit', [$customer->id, $attachedAddress->id]))
            ->assertStatus(200)
            ->assertSee($address->alias);
    }

    /** @test */
    public function it_can_show_the_customer_address()
    {
        factory(City::class)->create();
        $customer = factory(Customer::class)->create();
        $address = factory(Address::class)->create();

        $customerRepo = new CustomerRepository($customer);
        $customerRepo->attachAddress($address);

        $this
            ->actingAs($this->employee, 'employee')
            ->get(route('admin.customers.addresses.show', [$customer->id, $address->id]))
            ->assertStatus(200)
            ->assertSee($address->alias);
    }

    /** @test */
    public function it_can_delete_the_customer()
    {
        $customer = factory(Customer::class)->create();

        $this
            ->actingAs($this->employee, 'employee')
            ->delete(route('admin.customers.destroy', $customer->id))
            ->assertStatus(302)
            ->assertRedirect(route('admin.customers.index'))
            ->assertSessionHas('message', 'Delete successful');
    }

    /** @test */
    public function it_can_show_the_create_and_edit_page()
    {
        $customer = factory(Customer::class)->create();

        $this
            ->actingAs($this->employee, 'employee')
            ->get(route('admin.customers.create'))
            ->assertStatus(200);

        $this
            ->actingAs($this->employee, 'employee')
            ->get(route('admin.customers.edit', $customer->id))
            ->assertStatus(200)
            ->assertSee(htmlentities($customer->first_name, ENT_QUOTES));
    }

    /** @test */
    public function it_can_search_for_the_customer()
    {
        $customer = factory(Customer::class)->create();

        $param = ['q' => Str::slug($customer->first_name, 5)];

        $this
            ->actingAs($this->employee, 'employee')
            ->get(route('admin.customers.index', $param))
            ->assertStatus(200);
    }

    /** @test */
    public function it_can_update_the_customers_password()
    {
        $customer = factory(Customer::class)->create();

        $data = [
            'first_name' => $this->faker->name,
            'email' => $this->faker->email,
            'password' => 'unknown'
        ];

        $this->actingAs($this->employee, 'employee')
            ->put(route('admin.customers.update', $customer->id), $data)
            ->assertStatus(302)
            ->assertRedirect(route('admin.customers.edit', $customer->id));
    }

    /** @test */
    public function it_can_show_all_the_customers()
    {
        factory(Customer::class, 20)->create();

        $this->actingAs($this->employee, 'employee')
            ->get(route('admin.customers.index'))
            ->assertViewHas(['customers']);
    }

    /** @test */
    public function it_can_show_the_customer()
    {
        $customer = factory(Customer::class)->create();

        $this->actingAs($this->employee, 'employee')
            ->get(route('admin.customers.show', $customer->id))
            ->assertViewHas(['customer'])
            ->assertSeeText(htmlentities($customer->first_name, ENT_QUOTES));
    }

    /** @test */
    public function it_can_update_the_customer()
    {
        $customer = factory(Customer::class)->create();

        $data = [
            'first_name' => $this->faker->name,
            'email' => $this->faker->email
        ];

        $this->actingAs($this->employee, 'employee')
            ->put(route('admin.customers.update', $customer->id), $data)
            ->assertStatus(302)
            ->assertRedirect(route('admin.customers.edit', $customer->id));

        $this->assertDatabaseHas('customers', $data);
    }

    /** @test */
    public function it_can_create_the_customer()
    {
        $data = [
            'first_name' => $this->faker->name,
            'email' => $this->faker->email,
            'password' => 'secret!!'
        ];

        $this->actingAs($this->employee, 'employee')
            ->post(route('admin.customers.store'), $data)
            ->assertStatus(302)
            ->assertRedirect(route('admin.customers.index'));

        $created = collect($data)->except('password');

        $this->assertDatabaseHas('customers', $created->all());
    }
}

Spamworldpro Mini