-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47bad53
commit 4601fa6
Showing
4 changed files
with
45 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
C:37:"PHPUnit\Runner\DefaultTestResultCache":1256:{a:2:{s:7:"defects";a:7:{s:74:"Tests\Feature\ArticleTest::that_only_loading_articles_for_provided_user_id";i:4;s:49:"Tests\Feature\ArticleTest::that_load_all_articles";i:4;s:62:"Tests\Feature\ArticleTest::that_loaded_only_published_articles";i:4;s:59:"Tests\Feature\ArticleTest::that_load_only_published_article";i:4;s:95:"Tests\Feature\ArticleTest::that_article_get_published_and_total_number_of_published_get_changed";i:4;s:99:"Tests\Feature\ArticleTest::that_article_get_unpublished_and_total_number_of_unpublished_get_changed";i:4;s:44:"Tests\Feature\LoginTest::test_user_can_login";i:3;}s:5:"times";a:8:{s:74:"Tests\Feature\ArticleTest::that_only_loading_articles_for_provided_user_id";d:1.668;s:49:"Tests\Feature\ArticleTest::that_load_all_articles";d:0.541;s:62:"Tests\Feature\ArticleTest::that_loaded_only_published_articles";d:0.376;s:59:"Tests\Feature\ArticleTest::that_load_only_published_article";d:0.556;s:95:"Tests\Feature\ArticleTest::that_article_get_published_and_total_number_of_published_get_changed";d:0.438;s:99:"Tests\Feature\ArticleTest::that_article_get_unpublished_and_total_number_of_unpublished_get_changed";d:0.419;s:44:"Tests\Feature\LoginTest::test_user_can_login";d:1.037;s:37:"Tests\Unit\ExampleTest::testBasicTest";d:0.21;}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,12 @@ | |
|
||
namespace Tests\Feature; | ||
|
||
use App\Article; | ||
use App\User; | ||
use App\Article; | ||
use Carbon\Carbon; | ||
use Symfony\Component\HttpKernel\Tests\Exception\NotFoundHttpExceptionTest; | ||
use Tests\TestCase; | ||
use Illuminate\Foundation\Testing\WithoutMiddleware; | ||
use Illuminate\Foundation\Testing\DatabaseMigrations; | ||
use Illuminate\Foundation\Testing\DatabaseTransactions; | ||
use Illuminate\Support\Str; | ||
|
||
class ArticleTest extends TestCase | ||
{ | ||
|
@@ -24,6 +22,17 @@ public function setUp(): void | |
$this->user = $this->createAdminUser(); | ||
} | ||
|
||
private function createAdminUser() | ||
{ | ||
return User::create([ | ||
'name' => 'Moeen Basra', | ||
'email' => '[email protected]', | ||
'password' => bcrypt('secret'), | ||
'is_admin' => true, | ||
'remember_token' => Str::random(10), | ||
]); | ||
} | ||
|
||
/** @test */ | ||
public function that_only_loading_articles_for_provided_user_id() | ||
{ | ||
|
@@ -35,6 +44,14 @@ public function that_only_loading_articles_for_provided_user_id() | |
|
||
} | ||
|
||
private function seedUnpublishedArticles($num = 15) | ||
{ | ||
factory(Article::class, $num)->create([ | ||
'user_id' => $this->user->id, | ||
'published' => false, | ||
]); | ||
} | ||
|
||
/** @test */ | ||
public function that_load_all_articles() | ||
{ | ||
|
@@ -55,6 +72,14 @@ public function that_loaded_only_published_articles() | |
$this->assertCount(5, $articles); | ||
} | ||
|
||
private function seedPublishedArticles($num = 5) | ||
{ | ||
factory(Article::class, $num)->create([ | ||
'user_id' => $this->user->id, | ||
'published' => true, | ||
]); | ||
} | ||
|
||
/** @test */ | ||
public function that_load_only_published_article() | ||
{ | ||
|
@@ -109,31 +134,4 @@ public function that_article_get_unpublished_and_total_number_of_unpublished_get | |
|
||
$this->assertEquals($articles->count(), 6); | ||
} | ||
|
||
private function seedUnpublishedArticles($num = 15) | ||
{ | ||
factory(Article::class, $num)->create([ | ||
'user_id' => $this->user->id, | ||
'published' => false, | ||
]); | ||
} | ||
|
||
private function seedPublishedArticles($num = 5) | ||
{ | ||
factory(Article::class, $num)->create([ | ||
'user_id' => $this->user->id, | ||
'published' => true, | ||
]); | ||
} | ||
|
||
private function createAdminUser() | ||
{ | ||
return User::create([ | ||
'name' => 'Moeen Basra', | ||
'email' => '[email protected]', | ||
'password' => bcrypt('secret'), | ||
'is_admin' => true, | ||
'remember_token' => str_random(10), | ||
]); | ||
} | ||
} |