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