The existing price values are divided by 100 in front-end as you mention after adding accesor/mutator.
Creating new activities, the price value is multiplied by 100 and saved in the DB, but in front-end the value is the same as the one entered. what is the goal for the new values??
Question since I am using the Uuid for the user and the user is being referenced in the guide_id and again in the StoreActivityRequest.php file do I need to replace it with the foreignUuid ?
FAILED Tests\Feature\CompanyActivityTest > can upload image
Unable to find a file or directory at path [o6Kjk8xnngz9MFO2D5E3DwJcneAEp3xpPXy23HPA.jpg].
Failed asserting that false is true.
at vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php:119
115▕
116▕ $paths = Arr::wrap($path);
117▕
118▕ foreach ($paths as $path) {
➜ 119▕ PHPUnit::assertTrue(
120▕ $this->exists($path), "Unable to find a file or directory at path [{$path}]."
121▕ );
122▕
123▕ if (! is_null($content)) {
With Storage::fake('activities') we would fake a so-called disk named 'activities'. In our filesystems.php there's no disk declared as 'activities'.
In our CompanyActivityController we're saving to the subdirectory 'activities' on 'public' disk, so for making our test work, we should fake this disk:
Awesome tutorial, I'm learning a bunch of new stuff, however I can get pass testing phase in this step.
From 14 tests ony 4 are passing, and I see 2 recurring issues:
Call to undefined relationship [activities] on model [App\Models\Company].
and
FAILED Tests\Feature\CompanyActivityTest > admin can edit activity for company ────────────────────────────────────────────────
Error Error
Class "Database\Factories\Factory" not found
at database\factories\ActivityFactory.php:9
5▕ use App\Models\Company;
6▕ use Illuminate\Support\Carbon;
7▕
8▕
➜ 9▕ class ActivityFactory extends Factory
10▕ {
11▕ public function definition(): array
12▕ {
13▕ return [
Have I missed some steps (I have been doing this for the last few hours, and it is a posibility, although, I went with copy/past last time to ensure no typing error sneaks in) ?
For the first error you are missing the activities() relationship on the Company model.
For the second, maybe you are missing HasFactory trait on the model.
I did create the model using artisan.
I was not aware that completing this cours has a pre-requisite on knowing stuff (that I don't know) by heart especially as I did not worked with factorie untill now.
Having a bit of an issue with your use statement and the activity::class it seems to have a mismatch,
Yes, correct, well spotted! Fixed now.
Sorry but I just realized that you never created the Activity Model or at least I can’t find it.
I can see where you added
All the database and models have been created in the first lesson.
The existing price values are divided by 100 in front-end as you mention after adding accesor/mutator. Creating new activities, the price value is multiplied by 100 and saved in the DB, but in front-end the value is the same as the one entered. what is the goal for the new values??
Question since I am using the Uuid for the user and the user is being referenced in the guide_id and again in the StoreActivityRequest.php file do I need to replace it with the foreignUuid ?
Yes, most likely.
For some reason the below test is throwing an error and i cant seem to figure out why.
public function test_can_upload_image() { Storage::fake('activities');
I get the follwing error
FAILED Tests\Feature\CompanyActivityTest > can upload image
Unable to find a file or directory at path [o6Kjk8xnngz9MFO2D5E3DwJcneAEp3xpPXy23HPA.jpg]. Failed asserting that false is true.
at vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php:119 115▕ 116▕ $paths = Arr::wrap($path); 117▕ 118▕ foreach ($paths as $path) { ➜ 119▕ PHPUnit::assertTrue( 120▕ $this->exists($path), "Unable to find a file or directory at path [{$path}]." 121▕ ); 122▕ 123▕ if (! is_null($content)) {
2 tests/Feature/CompanyActivityTest.php:86
With
Storage::fake('activities')we would fake a so-called disk named 'activities'. In ourfilesystems.phpthere's no disk declared as 'activities'.In our
CompanyActivityControllerwe're saving to the subdirectory 'activities' on 'public' disk, so for making our test work, we should fake this disk:Also use this disk then for the assertions:
Hi all,
Awesome tutorial, I'm learning a bunch of new stuff, however I can get pass testing phase in this step. From 14 tests ony 4 are passing, and I see 2 recurring issues:
and
Have I missed some steps (I have been doing this for the last few hours, and it is a posibility, although, I went with copy/past last time to ensure no typing error sneaks in) ?
For the first error you are missing the
activities()relationship on theCompanymodel. For the second, maybe you are missingHasFactorytrait on the model.I understood that, but I'm unable to find the step in this tutorial where it sais I should do that.
The second issue us due to not having an import declared on ActivityFactory.php because, again is not mentioned anywhere in here that is should be.
I'm down to my last issue, and this one I have no clue on how to solve it:
Any suggestion on how I can overcome this obstacle?
Much appreciated!
When you create a model using an artisan command the trait is always added. Also, when using factories you must know about this trait.
I did create the model using artisan. I was not aware that completing this cours has a pre-requisite on knowing stuff (that I don't know) by heart especially as I did not worked with factorie untill now.