samedi 5 septembre 2020

Laravel testing store method

Hello i would like to test a store method in laravel. In the store method has simple data and image. The faker generate all data, image as well but the validator not accepte the image. Why is this happend? The faker generate correct image name and extension.

Here is the test case

    public function test_an_authenticated_user_can_add_new_companie () 
    {
        $companies = factory(Companies::class)->create();

        $company = $companies->toArray();

        $this->actingAs($this->user);
        $response = $this->postJson('/home/companies/create/add', $company);
        $response->assertStatus(302);
    }

And here is the factory

        'name' => $faker->company,
        'email' => $faker->email,
        'logo' => $faker->image(public_path('img\logos'), 100, 100, null, false),
        'website' => $faker->url,

Aucun commentaire:

Enregistrer un commentaire