mirror of
https://github.com/brunofontes/shareit.git
synced 2024-11-24 04:14:57 +00:00
Including first Laravel UnitText Experience
These changes will stay here so I can use them as examples to come back later to include some real tests.
This commit is contained in:
parent
a905d98304
commit
8c0e46538c
@ -21,3 +21,12 @@ $factory->define(App\User::class, function (Faker $faker) {
|
|||||||
'remember_token' => str_random(10),
|
'remember_token' => str_random(10),
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$factory->define(App\Product::class, function (Faker $faker) {
|
||||||
|
return [
|
||||||
|
'name' => $faker->sentence,
|
||||||
|
'user_id' => function () {
|
||||||
|
return factory(App\User::class)->create()->id;
|
||||||
|
},
|
||||||
|
];
|
||||||
|
});
|
@ -29,5 +29,6 @@
|
|||||||
<env name="SESSION_DRIVER" value="array"/>
|
<env name="SESSION_DRIVER" value="array"/>
|
||||||
<env name="QUEUE_CONNECTION" value="sync"/>
|
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||||
<env name="MAIL_DRIVER" value="array"/>
|
<env name="MAIL_DRIVER" value="array"/>
|
||||||
|
<env name="DB_DATABASE" value="shareit_test"/>
|
||||||
</php>
|
</php>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
@ -2,11 +2,14 @@
|
|||||||
|
|
||||||
namespace Tests\Feature;
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use \App\Product;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
class ExampleTest extends TestCase
|
class ExampleTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A basic test example.
|
* A basic test example.
|
||||||
*
|
*
|
||||||
@ -14,8 +17,16 @@ class ExampleTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testBasicTest()
|
public function testBasicTest()
|
||||||
{
|
{
|
||||||
$response = $this->get('/');
|
|
||||||
|
|
||||||
|
$response = $this->get('/');
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
|
|
||||||
|
//Just to remember the assertSee
|
||||||
|
$this->get('/')->assertSee('Login');
|
||||||
|
|
||||||
|
//Learning how to make unit tests with Laravel
|
||||||
|
factory(Product::class)->create();
|
||||||
|
$products = Product::all();
|
||||||
|
$this->assertCount(1, $products);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user