diff --git a/composer.json b/composer.json
index de605fc4..67731974 100644
--- a/composer.json
+++ b/composer.json
@@ -33,7 +33,8 @@
"psr-4": {
"App\\": "app/",
"Modules\\": "modules/",
- "Templates\\": "templates/"
+ "Templates\\": "templates/",
+ "Tests\\": "tests/"
}
},
"scripts": {
diff --git a/phpunit.xml b/phpunit.xml
index cc0841c1..31e6bced 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -9,8 +9,8 @@
processIsolation="false"
stopOnFailure="false">
-
- ./tests/
+
+ ./tests/unit/
@@ -23,5 +23,6 @@
+
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 8578b17e..dd330286 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -1,6 +1,10 @@
make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
+ $app->make(Kernel::class)->bootstrap();
return $app;
}
diff --git a/tests/WritePermissionsTest.php b/tests/WritePermissionsTest.php
deleted file mode 100644
index 7ff13f02..00000000
--- a/tests/WritePermissionsTest.php
+++ /dev/null
@@ -1,47 +0,0 @@
-writeToDir(storage_path('test.txt'));
- }
-
- public function testLogsDir()
- {
- $this->writeToDir(storage_path('logs/test.txt'));
- }
-
- public function testFrameworkDir()
- {
- $this->writeToDir(storage_path('framework/test.txt'));
- }
-
- public function testBootstrapCacheDir()
- {
- $this->writeToDir(storage_path('../bootstrap/cache/test.txt'));
- }
-
- public function testUploadDir()
- {
- $this->writeToDir(config('app.upload_path').'/test.txt');
- }
-
- /**
- * Create and delete some file
- *
- * @param $path
- */
- protected function writeToDir($file)
- {
- $content = uniqid();
- $bytesWritten = file_put_contents($file, $content);
-
- // test writing
- $this->assertNotFalse($bytesWritten);
-
- // test deleting
- $deleted = @unlink($file);
- $this->assertTrue($deleted);
- }
-}
diff --git a/tests/unit/admin/content/ContentModelTest.php b/tests/unit/admin/content/ContentModelTest.php
new file mode 100644
index 00000000..69dcd998
--- /dev/null
+++ b/tests/unit/admin/content/ContentModelTest.php
@@ -0,0 +1,58 @@
+createApplication();
+
+ $this->content = App::make(Content::class);
+
+ // create new rows
+ $this->user = factory(User::class)->create();
+ $this->parentPage = factory(ContentModel::class)->create(['userId' => $this->user->id]);
+ factory(ContentModel::class, 4)->create(['userId' => $this->user->id]);
+ factory(ContentModel::class, 5)->create([
+ 'userId' => $this->user->id,
+ 'parentId' => $this->parentPage->id
+ ]);
+ }
+
+ public function testSubpages() {
+
+ $subpages = $this->parentPage->subpages;
+
+ $this->assertTrue($subpages instanceof Collection);
+ $this->assertCount(5, $subpages);
+ }
+
+ function __destruct()
+ {
+ // clean tables
+ ContentModel::getQuery()
+ ->delete();
+ }
+}
+
diff --git a/tests/unit/admin/content/CreatingNewContentTest.php b/tests/unit/admin/content/CreatingNewContentTest.php
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/unit/admin/content/EditingContentTest.php b/tests/unit/admin/content/EditingContentTest.php
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/unit/admin/content/RepositoryReadTest.php b/tests/unit/admin/content/RepositoryReadTest.php
new file mode 100644
index 00000000..0320b2a1
--- /dev/null
+++ b/tests/unit/admin/content/RepositoryReadTest.php
@@ -0,0 +1,108 @@
+createApplication();
+
+ // clean tables
+ ContentModel::getQuery()
+ ->delete();
+ User::getQuery()
+ ->delete();
+
+ $this->content = App::make(Content::class);
+
+ // create new rows
+ $this->user = factory(User::class)->create();
+ factory(ContentModel::class, 3)->create(['userId' => $this->user->id, 'status' => Content::STATUS_DRAFT]);
+ factory(ContentModel::class, 1)->create(['userId' => $this->user->id, 'status' => Content::STATUS_PROTECTED]);
+ factory(ContentModel::class, 5)->create(['userId' => $this->user->id, 'status' => Content::STATUS_PUBLIC]);
+ }
+
+ /**
+ * Test for selecting homepage.
+ *
+ * At first, it tries to select non-existing homepage. On second try, homepage is created.
+ */
+ public function testSelectingHomepage()
+ {
+ $homepage = $this->content->getHomepage();
+ $this->assertNull($homepage);
+
+ $newHomepage = factory(ContentModel::class)->create([
+ 'userId' => $this->user->id,
+ 'isHomepage' => 1,
+ 'status' => Content::STATUS_PUBLIC,
+ 'publishedFrom' => Carbon::now()
+ ->subDays(10)
+ ]);
+
+ $homepage = $this->content->getHomepage();
+ $this->assertNotNull($homepage);
+ $this->assertTrue($homepage->id === $newHomepage->id);
+ }
+
+ public function testSelectingAllPages()
+ {
+ $all = $this->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()
+ // {
+ // }
+}
\ No newline at end of file