From 983efad9f07ec343e285813ed52abc69819b0845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kv=C3=A1=C4=8Dek?= Date: Sat, 2 Sep 2017 00:35:52 +0200 Subject: [PATCH] TESTING #1931: do something with tests.. Not really usefull --- database/factories/ModelFactory.php | 5 +- phpunit.xml | 2 +- .../Content}/ContentModelTest.php | 2 +- .../Content}/RepositoryReadTest.php | 62 +++++++------------ .../admin/content/CreatingNewContentTest.php | 0 .../unit/admin/content/EditingContentTest.php | 0 6 files changed, 29 insertions(+), 42 deletions(-) rename tests/{unit/admin/content => Unit/Content}/ContentModelTest.php (97%) rename tests/{unit/admin/content => Unit/Content}/RepositoryReadTest.php (73%) delete mode 100644 tests/unit/admin/content/CreatingNewContentTest.php delete mode 100644 tests/unit/admin/content/EditingContentTest.php diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 96f72d25..4eb4ec98 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -28,10 +28,13 @@ $factory->define(User::class, function (Faker\Generator $faker) { }); $factory->define(Content::class, function (Faker\Generator $faker) { + + $slug = isset($faker->slug) ? $faker->slug : $faker->slug(5); + return [ 'title' => $faker->sentence(5), 'userId' => 1, - 'url' => $faker->slug(5), + 'url' => $slug, 'pageContent' => $faker->text(1500), 'metaDescription' => $faker->text, 'moduleHandler' => config('staticpages.handler'), diff --git a/phpunit.xml b/phpunit.xml index 31e6bced..e0a0855e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -10,7 +10,7 @@ stopOnFailure="false"> - ./tests/unit/ + ./tests/Unit/ diff --git a/tests/unit/admin/content/ContentModelTest.php b/tests/Unit/Content/ContentModelTest.php similarity index 97% rename from tests/unit/admin/content/ContentModelTest.php rename to tests/Unit/Content/ContentModelTest.php index 69dcd998..23cba677 100644 --- a/tests/unit/admin/content/ContentModelTest.php +++ b/tests/Unit/Content/ContentModelTest.php @@ -1,5 +1,5 @@ content->all(); - $this->assertCount(6, $all); } - // public function testContentVisibilityByPublishedFrom() - // { - // } - // - // public function testContentVisibilityByPublishedTo() - // { - // } - // - // public function testSelectingByURL() - // { - // - // } - // - // public function testSelectingById() - // { - // } - // - // public function testSelectingInvalidPageByURL() - // { - // } - // - // public function testSelectingInvalidPageById() - // { - // } - // - // public function testOverview() - // { - // } - // - // public function testOvervieWithOneStatus() - // { - // } - // - // public function testOverviewWithMultipleStatuses() - // { - // } + public function testSelectingByURL() + { + $slug = 'testing-slug-for-testing-purposes'; + factory(ContentModel::class, 3)->create([ + 'userId' => $this->user->id, + 'status' => Content::STATUS_PUBLIC, + 'url' => $slug + ]); + + $page = $this->content->getByURL($slug); + + $this->assertNotNull($page); + $this->assertTrue($page->exists); + } + + public function testSelectingInvalidPageByURL() + { + $invalidPage = $this->content->getByURL('non-existing-url'); + + $this->assertNull($invalidPage); + } } \ No newline at end of file diff --git a/tests/unit/admin/content/CreatingNewContentTest.php b/tests/unit/admin/content/CreatingNewContentTest.php deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/unit/admin/content/EditingContentTest.php b/tests/unit/admin/content/EditingContentTest.php deleted file mode 100644 index e69de29b..00000000