Commit 75264183 authored by Vipul Basapati's avatar Vipul Basapati

Blog Tests completed

parent a6019896
...@@ -2,19 +2,20 @@ ...@@ -2,19 +2,20 @@
namespace App\Repositories\Backend\Blogs; namespace App\Repositories\Backend\Blogs;
use App\Events\Backend\Blogs\BlogCreated; use DB;
use Carbon\Carbon;
use App\Models\Blogs\Blog;
use App\Models\BlogTags\BlogTag;
use App\Http\Utilities\FileUploads;
use App\Exceptions\GeneralException;
use App\Repositories\BaseRepository;
use App\Models\BlogMapTags\BlogMapTag;
use Illuminate\Support\Facades\Storage;
use App\Events\Backend\Blogs\BlogDeleted; use App\Events\Backend\Blogs\BlogDeleted;
use App\Events\Backend\Blogs\BlogUpdated; use App\Events\Backend\Blogs\BlogUpdated;
use App\Exceptions\GeneralException; use App\Events\Backend\Blogs\BlogCreated;
use App\Http\Utilities\FileUploads;
use App\Models\BlogCategories\BlogCategory; use App\Models\BlogCategories\BlogCategory;
use App\Models\BlogMapCategories\BlogMapCategory; use App\Models\BlogMapCategories\BlogMapCategory;
use App\Models\BlogMapTags\BlogMapTag;
use App\Models\Blogs\Blog;
use App\Models\BlogTags\BlogTag;
use App\Repositories\BaseRepository;
use Carbon\Carbon;
use DB;
/** /**
* Class BlogsRepository. * Class BlogsRepository.
...@@ -26,6 +27,21 @@ class BlogsRepository extends BaseRepository ...@@ -26,6 +27,21 @@ class BlogsRepository extends BaseRepository
*/ */
const MODEL = Blog::class; const MODEL = Blog::class;
protected $upload_path;
/**
* Storage Class Object.
*
* @var \Illuminate\Support\Facades\Storage
*/
protected $storage;
public function __construct()
{
$this->upload_path = 'img' . DIRECTORY_SEPARATOR . 'blog' . DIRECTORY_SEPARATOR;
$this->storage = Storage::disk('public');
}
/** /**
* @return mixed * @return mixed
*/ */
...@@ -210,13 +226,12 @@ class BlogsRepository extends BaseRepository ...@@ -210,13 +226,12 @@ class BlogsRepository extends BaseRepository
*/ */
public function uploadImage($input) public function uploadImage($input)
{ {
$uploadManager = new FileUploads();
$avatar = $input['featured_image']; $avatar = $input['featured_image'];
if (isset($input['featured_image']) && !empty($input['featured_image'])) { if (isset($input['featured_image']) && !empty($input['featured_image'])) {
$fileName = $uploadManager->setBasePath('backend/blog_images') $fileName = time() . $avatar->getClientOriginalName();
->setThumbnailFlag(false)
->upload($input['featured_image']); $this->storage->put($this->upload_path . $fileName, file_get_contents($avatar->getRealPath()));
$input = array_merge($input, ['featured_image' => $fileName]); $input = array_merge($input, ['featured_image' => $fileName]);
...@@ -231,11 +246,8 @@ class BlogsRepository extends BaseRepository ...@@ -231,11 +246,8 @@ class BlogsRepository extends BaseRepository
*/ */
public function deleteOldFile($model) public function deleteOldFile($model)
{ {
$uploadManager = new FileUploads();
$fileName = $model->featured_image; $fileName = $model->featured_image;
$filePath = $uploadManager->setBasePath('backend/blog_images');
$file = $filePath->filePath.DIRECTORY_SEPARATOR.$fileName; return $this->storage->delete($this->upload_path . $fileName);
return $uploadManager->deleteFile($file);
} }
} }
...@@ -1472,16 +1472,16 @@ ...@@ -1472,16 +1472,16 @@
}, },
{ {
"name": "laravel/framework", "name": "laravel/framework",
"version": "v5.5.27", "version": "v5.5.28",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/framework.git", "url": "https://github.com/laravel/framework.git",
"reference": "b4fb6eeb227b7327b4ca7f92263b693ec9ac9875" "reference": "cfafae1f2043208390a7c984e3070696f4969605"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/b4fb6eeb227b7327b4ca7f92263b693ec9ac9875", "url": "https://api.github.com/repos/laravel/framework/zipball/cfafae1f2043208390a7c984e3070696f4969605",
"reference": "b4fb6eeb227b7327b4ca7f92263b693ec9ac9875", "reference": "cfafae1f2043208390a7c984e3070696f4969605",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -1602,7 +1602,7 @@ ...@@ -1602,7 +1602,7 @@
"framework", "framework",
"laravel" "laravel"
], ],
"time": "2017-12-20T15:43:48+00:00" "time": "2017-12-26T16:24:40+00:00"
}, },
{ {
"name": "laravel/socialite", "name": "laravel/socialite",
...@@ -2180,16 +2180,16 @@ ...@@ -2180,16 +2180,16 @@
}, },
{ {
"name": "nikic/php-parser", "name": "nikic/php-parser",
"version": "v3.1.2", "version": "v3.1.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nikic/PHP-Parser.git", "url": "https://github.com/nikic/PHP-Parser.git",
"reference": "08131e7ff29de6bb9f12275c7d35df71f25f4d89" "reference": "579f4ce846734a1cf55d6a531d00ca07a43e3cda"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/08131e7ff29de6bb9f12275c7d35df71f25f4d89", "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/579f4ce846734a1cf55d6a531d00ca07a43e3cda",
"reference": "08131e7ff29de6bb9f12275c7d35df71f25f4d89", "reference": "579f4ce846734a1cf55d6a531d00ca07a43e3cda",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -2227,7 +2227,7 @@ ...@@ -2227,7 +2227,7 @@
"parser", "parser",
"php" "php"
], ],
"time": "2017-11-04T11:48:34+00:00" "time": "2017-12-26T14:43:21+00:00"
}, },
{ {
"name": "paragonie/random_compat", "name": "paragonie/random_compat",
...@@ -2473,16 +2473,16 @@ ...@@ -2473,16 +2473,16 @@
}, },
{ {
"name": "psy/psysh", "name": "psy/psysh",
"version": "v0.8.16", "version": "v0.8.17",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/bobthecow/psysh.git", "url": "https://github.com/bobthecow/psysh.git",
"reference": "d4c8eab0683dc056f2ca54ca67f5388527c068b1" "reference": "5069b70e8c4ea492c2b5939b6eddc78bfe41cfec"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/d4c8eab0683dc056f2ca54ca67f5388527c068b1", "url": "https://api.github.com/repos/bobthecow/psysh/zipball/5069b70e8c4ea492c2b5939b6eddc78bfe41cfec",
"reference": "d4c8eab0683dc056f2ca54ca67f5388527c068b1", "reference": "5069b70e8c4ea492c2b5939b6eddc78bfe41cfec",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -2541,7 +2541,7 @@ ...@@ -2541,7 +2541,7 @@
"interactive", "interactive",
"shell" "shell"
], ],
"time": "2017-12-10T21:49:27+00:00" "time": "2017-12-28T16:14:16+00:00"
}, },
{ {
"name": "ramsey/uuid", "name": "ramsey/uuid",
...@@ -2682,16 +2682,16 @@ ...@@ -2682,16 +2682,16 @@
}, },
{ {
"name": "symfony/console", "name": "symfony/console",
"version": "v3.4.2", "version": "v3.4.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/console.git", "url": "https://github.com/symfony/console.git",
"reference": "9f21adfb92a9315b73ae2ed43138988ee4913d4e" "reference": "8394c8ef121949e8f858f13bc1e34f05169e4e7d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/9f21adfb92a9315b73ae2ed43138988ee4913d4e", "url": "https://api.github.com/repos/symfony/console/zipball/8394c8ef121949e8f858f13bc1e34f05169e4e7d",
"reference": "9f21adfb92a9315b73ae2ed43138988ee4913d4e", "reference": "8394c8ef121949e8f858f13bc1e34f05169e4e7d",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -2747,20 +2747,20 @@ ...@@ -2747,20 +2747,20 @@
], ],
"description": "Symfony Console Component", "description": "Symfony Console Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-12-14T19:40:10+00:00" "time": "2018-01-03T07:37:34+00:00"
}, },
{ {
"name": "symfony/css-selector", "name": "symfony/css-selector",
"version": "v3.4.2", "version": "v3.4.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/css-selector.git", "url": "https://github.com/symfony/css-selector.git",
"reference": "eac760b414cf1f64362c3dd047b989e4db121332" "reference": "e66394bc7610e69279bfdb3ab11b4fe65403f556"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/eac760b414cf1f64362c3dd047b989e4db121332", "url": "https://api.github.com/repos/symfony/css-selector/zipball/e66394bc7610e69279bfdb3ab11b4fe65403f556",
"reference": "eac760b414cf1f64362c3dd047b989e4db121332", "reference": "e66394bc7610e69279bfdb3ab11b4fe65403f556",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -2800,20 +2800,20 @@ ...@@ -2800,20 +2800,20 @@
], ],
"description": "Symfony CssSelector Component", "description": "Symfony CssSelector Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-12-14T19:40:10+00:00" "time": "2018-01-03T07:37:34+00:00"
}, },
{ {
"name": "symfony/debug", "name": "symfony/debug",
"version": "v3.4.2", "version": "v3.4.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/debug.git", "url": "https://github.com/symfony/debug.git",
"reference": "543deab3ffff94402440b326fc94153bae2dfa7a" "reference": "603b95dda8b00020e4e6e60dc906e7b715b1c245"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/543deab3ffff94402440b326fc94153bae2dfa7a", "url": "https://api.github.com/repos/symfony/debug/zipball/603b95dda8b00020e4e6e60dc906e7b715b1c245",
"reference": "543deab3ffff94402440b326fc94153bae2dfa7a", "reference": "603b95dda8b00020e4e6e60dc906e7b715b1c245",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -2856,20 +2856,20 @@ ...@@ -2856,20 +2856,20 @@
], ],
"description": "Symfony Debug Component", "description": "Symfony Debug Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-12-12T08:27:14+00:00" "time": "2018-01-03T17:14:19+00:00"
}, },
{ {
"name": "symfony/event-dispatcher", "name": "symfony/event-dispatcher",
"version": "v4.0.2", "version": "v4.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/event-dispatcher.git", "url": "https://github.com/symfony/event-dispatcher.git",
"reference": "d4face19ed8002eec8280bc1c5ec18130472bf43" "reference": "74d33aac36208c4d6757807d9f598f0133a3a4eb"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d4face19ed8002eec8280bc1c5ec18130472bf43", "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/74d33aac36208c4d6757807d9f598f0133a3a4eb",
"reference": "d4face19ed8002eec8280bc1c5ec18130472bf43", "reference": "74d33aac36208c4d6757807d9f598f0133a3a4eb",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -2919,20 +2919,20 @@ ...@@ -2919,20 +2919,20 @@
], ],
"description": "Symfony EventDispatcher Component", "description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-12-14T19:48:22+00:00" "time": "2018-01-03T07:38:00+00:00"
}, },
{ {
"name": "symfony/finder", "name": "symfony/finder",
"version": "v3.4.2", "version": "v3.4.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/finder.git", "url": "https://github.com/symfony/finder.git",
"reference": "dac8d7db537bac7ad8143eb11360a8c2231f251a" "reference": "613e26310776f49a1773b6737c6bd554b8bc8c6f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/dac8d7db537bac7ad8143eb11360a8c2231f251a", "url": "https://api.github.com/repos/symfony/finder/zipball/613e26310776f49a1773b6737c6bd554b8bc8c6f",
"reference": "dac8d7db537bac7ad8143eb11360a8c2231f251a", "reference": "613e26310776f49a1773b6737c6bd554b8bc8c6f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -2968,20 +2968,20 @@ ...@@ -2968,20 +2968,20 @@
], ],
"description": "Symfony Finder Component", "description": "Symfony Finder Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-11-05T16:10:10+00:00" "time": "2018-01-03T07:37:34+00:00"
}, },
{ {
"name": "symfony/http-foundation", "name": "symfony/http-foundation",
"version": "v3.4.2", "version": "v3.4.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/http-foundation.git", "url": "https://github.com/symfony/http-foundation.git",
"reference": "59bf131b5460227a2f583a7dbe6b179f98f9e0a5" "reference": "4a213be1cc8598089b8c7451529a2927b49b5d26"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/59bf131b5460227a2f583a7dbe6b179f98f9e0a5", "url": "https://api.github.com/repos/symfony/http-foundation/zipball/4a213be1cc8598089b8c7451529a2927b49b5d26",
"reference": "59bf131b5460227a2f583a7dbe6b179f98f9e0a5", "reference": "4a213be1cc8598089b8c7451529a2927b49b5d26",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -3022,20 +3022,20 @@ ...@@ -3022,20 +3022,20 @@
], ],
"description": "Symfony HttpFoundation Component", "description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-12-14T19:40:10+00:00" "time": "2018-01-03T17:14:19+00:00"
}, },
{ {
"name": "symfony/http-kernel", "name": "symfony/http-kernel",
"version": "v3.4.2", "version": "v3.4.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/http-kernel.git", "url": "https://github.com/symfony/http-kernel.git",
"reference": "48325096bbda77b983e642d21a4dd9bdde3ab73e" "reference": "1c2a82d6a8ec9b354fe4ef48ad1ad3f1a4f7db0e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/48325096bbda77b983e642d21a4dd9bdde3ab73e", "url": "https://api.github.com/repos/symfony/http-kernel/zipball/1c2a82d6a8ec9b354fe4ef48ad1ad3f1a4f7db0e",
"reference": "48325096bbda77b983e642d21a4dd9bdde3ab73e", "reference": "1c2a82d6a8ec9b354fe4ef48ad1ad3f1a4f7db0e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -3110,7 +3110,7 @@ ...@@ -3110,7 +3110,7 @@
], ],
"description": "Symfony HttpKernel Component", "description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-12-15T02:05:18+00:00" "time": "2018-01-05T08:33:00+00:00"
}, },
{ {
"name": "symfony/polyfill-mbstring", "name": "symfony/polyfill-mbstring",
...@@ -3340,16 +3340,16 @@ ...@@ -3340,16 +3340,16 @@
}, },
{ {
"name": "symfony/process", "name": "symfony/process",
"version": "v3.4.2", "version": "v3.4.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/process.git", "url": "https://github.com/symfony/process.git",
"reference": "bb3ef65d493a6d57297cad6c560ee04e2a8f5098" "reference": "ff69f110c6b33fd33cd2089ba97d6112f44ef0ba"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/bb3ef65d493a6d57297cad6c560ee04e2a8f5098", "url": "https://api.github.com/repos/symfony/process/zipball/ff69f110c6b33fd33cd2089ba97d6112f44ef0ba",
"reference": "bb3ef65d493a6d57297cad6c560ee04e2a8f5098", "reference": "ff69f110c6b33fd33cd2089ba97d6112f44ef0ba",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -3385,20 +3385,20 @@ ...@@ -3385,20 +3385,20 @@
], ],
"description": "Symfony Process Component", "description": "Symfony Process Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-12-14T19:40:10+00:00" "time": "2018-01-03T07:37:34+00:00"
}, },
{ {
"name": "symfony/routing", "name": "symfony/routing",
"version": "v3.4.2", "version": "v3.4.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/routing.git", "url": "https://github.com/symfony/routing.git",
"reference": "5f248dfac5e4660c74982eb3dadc71cf58595570" "reference": "e2b6d6fe7b090c7af720b75c7722c6dfa7a52658"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/routing/zipball/5f248dfac5e4660c74982eb3dadc71cf58595570", "url": "https://api.github.com/repos/symfony/routing/zipball/e2b6d6fe7b090c7af720b75c7722c6dfa7a52658",
"reference": "5f248dfac5e4660c74982eb3dadc71cf58595570", "reference": "e2b6d6fe7b090c7af720b75c7722c6dfa7a52658",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -3463,20 +3463,20 @@ ...@@ -3463,20 +3463,20 @@
"uri", "uri",
"url" "url"
], ],
"time": "2017-12-14T22:37:31+00:00" "time": "2018-01-04T15:09:34+00:00"
}, },
{ {
"name": "symfony/translation", "name": "symfony/translation",
"version": "v3.4.2", "version": "v3.4.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/translation.git", "url": "https://github.com/symfony/translation.git",
"reference": "4c5d5582baf2829751a5207659329c1f52eedeb6" "reference": "17b5962d252b2d6d1d37a2485ebb7ddc5b2bef0a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/4c5d5582baf2829751a5207659329c1f52eedeb6", "url": "https://api.github.com/repos/symfony/translation/zipball/17b5962d252b2d6d1d37a2485ebb7ddc5b2bef0a",
"reference": "4c5d5582baf2829751a5207659329c1f52eedeb6", "reference": "17b5962d252b2d6d1d37a2485ebb7ddc5b2bef0a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -3531,20 +3531,20 @@ ...@@ -3531,20 +3531,20 @@
], ],
"description": "Symfony Translation Component", "description": "Symfony Translation Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-12-12T08:27:14+00:00" "time": "2018-01-03T07:37:34+00:00"
}, },
{ {
"name": "symfony/var-dumper", "name": "symfony/var-dumper",
"version": "v3.4.2", "version": "v3.4.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/var-dumper.git", "url": "https://github.com/symfony/var-dumper.git",
"reference": "757074cf71b952ce9e75b557538948811c2bf006" "reference": "545be7e78ccbec43e599f10ff7500d0b09eda9d0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/757074cf71b952ce9e75b557538948811c2bf006", "url": "https://api.github.com/repos/symfony/var-dumper/zipball/545be7e78ccbec43e599f10ff7500d0b09eda9d0",
"reference": "757074cf71b952ce9e75b557538948811c2bf006", "reference": "545be7e78ccbec43e599f10ff7500d0b09eda9d0",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -3600,20 +3600,20 @@ ...@@ -3600,20 +3600,20 @@
"debug", "debug",
"dump" "dump"
], ],
"time": "2017-12-11T22:06:16+00:00" "time": "2018-01-03T17:14:19+00:00"
}, },
{ {
"name": "symfony/yaml", "name": "symfony/yaml",
"version": "v4.0.2", "version": "v4.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/yaml.git", "url": "https://github.com/symfony/yaml.git",
"reference": "a5ee52d155f06ad23b19eb63c31228ff56ad1116" "reference": "b84f646b9490d2101e2c25ddeec77ceefbda2eee"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/a5ee52d155f06ad23b19eb63c31228ff56ad1116", "url": "https://api.github.com/repos/symfony/yaml/zipball/b84f646b9490d2101e2c25ddeec77ceefbda2eee",
"reference": "a5ee52d155f06ad23b19eb63c31228ff56ad1116", "reference": "b84f646b9490d2101e2c25ddeec77ceefbda2eee",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -3658,7 +3658,7 @@ ...@@ -3658,7 +3658,7 @@
], ],
"description": "Symfony Yaml Component", "description": "Symfony Yaml Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-12-12T08:41:51+00:00" "time": "2018-01-03T07:38:00+00:00"
}, },
{ {
"name": "tijsverkoyen/css-to-inline-styles", "name": "tijsverkoyen/css-to-inline-styles",
...@@ -3783,16 +3783,16 @@ ...@@ -3783,16 +3783,16 @@
}, },
{ {
"name": "unisharp/laravel-filemanager", "name": "unisharp/laravel-filemanager",
"version": "v1.8.3", "version": "v1.8.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/UniSharp/laravel-filemanager.git", "url": "https://github.com/UniSharp/laravel-filemanager.git",
"reference": "40ff56023e932c01b20dde0619b5fa81f17df06d" "reference": "ccbba303a3a66a9706b50c98923af12e2f9ac02a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/UniSharp/laravel-filemanager/zipball/40ff56023e932c01b20dde0619b5fa81f17df06d", "url": "https://api.github.com/repos/UniSharp/laravel-filemanager/zipball/ccbba303a3a66a9706b50c98923af12e2f9ac02a",
"reference": "40ff56023e932c01b20dde0619b5fa81f17df06d", "reference": "ccbba303a3a66a9706b50c98923af12e2f9ac02a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -3853,7 +3853,7 @@ ...@@ -3853,7 +3853,7 @@
"tinymce", "tinymce",
"upload" "upload"
], ],
"time": "2017-12-05T17:21:15+00:00" "time": "2017-12-28T09:23:53+00:00"
}, },
{ {
"name": "vlucas/phpdotenv", "name": "vlucas/phpdotenv",
...@@ -5159,16 +5159,16 @@ ...@@ -5159,16 +5159,16 @@
}, },
{ {
"name": "phpunit/phpunit-mock-objects", "name": "phpunit/phpunit-mock-objects",
"version": "5.0.5", "version": "5.0.6",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "283b9f4f670e3a6fd6c4ff95c51a952eb5c75933" "reference": "33fd41a76e746b8fa96d00b49a23dadfa8334cdf"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/283b9f4f670e3a6fd6c4ff95c51a952eb5c75933", "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/33fd41a76e746b8fa96d00b49a23dadfa8334cdf",
"reference": "283b9f4f670e3a6fd6c4ff95c51a952eb5c75933", "reference": "33fd41a76e746b8fa96d00b49a23dadfa8334cdf",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -5214,7 +5214,7 @@ ...@@ -5214,7 +5214,7 @@
"mock", "mock",
"xunit" "xunit"
], ],
"time": "2017-12-10T08:01:53+00:00" "time": "2018-01-06T05:45:45+00:00"
}, },
{ {
"name": "sebastian/code-unit-reverse-lookup", "name": "sebastian/code-unit-reverse-lookup",
...@@ -5777,16 +5777,16 @@ ...@@ -5777,16 +5777,16 @@
}, },
{ {
"name": "symfony/dom-crawler", "name": "symfony/dom-crawler",
"version": "v3.4.2", "version": "v3.4.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/dom-crawler.git", "url": "https://github.com/symfony/dom-crawler.git",
"reference": "dc847845c66fa68ad4522ed27e62b9b9dd12ab3b" "reference": "09bd97b844b3151fab82f2fdd62db9c464b3910a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/dc847845c66fa68ad4522ed27e62b9b9dd12ab3b", "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/09bd97b844b3151fab82f2fdd62db9c464b3910a",
"reference": "dc847845c66fa68ad4522ed27e62b9b9dd12ab3b", "reference": "09bd97b844b3151fab82f2fdd62db9c464b3910a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -5829,7 +5829,7 @@ ...@@ -5829,7 +5829,7 @@
], ],
"description": "Symfony DomCrawler Component", "description": "Symfony DomCrawler Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-12-14T19:40:10+00:00" "time": "2018-01-03T07:37:34+00:00"
}, },
{ {
"name": "theseer/tokenizer", "name": "theseer/tokenizer",
......
...@@ -12,6 +12,7 @@ $factory->define(Blog::class, function (Faker $faker) { ...@@ -12,6 +12,7 @@ $factory->define(Blog::class, function (Faker $faker) {
'InActive', 'InActive',
'Scheduled' 'Scheduled'
]; ];
return [ return [
'name' => $faker->sentence, 'name' => $faker->sentence,
'publish_datetime' => $faker->dateTime(), 'publish_datetime' => $faker->dateTime(),
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
{{ Form::label('featured_image', trans('validation.attributes.backend.blogs.image'), ['class' => 'col-lg-2 control-label required']) }} {{ Form::label('featured_image', trans('validation.attributes.backend.blogs.image'), ['class' => 'col-lg-2 control-label required']) }}
@if(!empty($blog->featured_image)) @if(!empty($blog->featured_image))
<div class="col-lg-1"> <div class="col-lg-1">
<img src="/img/backend/blog_images/{{$blog->featured_image}}" height="80" width="80"> <img src="{{ Storage::disk('public')->url('img/blog/' . $blog->featured_image) }}" height="80" width="80">
</div> </div>
<div class="col-lg-5"> <div class="col-lg-5">
<div class="custom-file-input"> <div class="custom-file-input">
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
</div> </div>
<div class="img-remove-logo"> <div class="img-remove-logo">
@if($setting->logo) @if($setting->logo)
<img height="50" width="50" src="{{ Storage::disk('public')->url('img/site_logo/' . $setting->logo) }}"> <img height="50" width="50" src="{{ Storage::disk('public')->url('img/logo/' . $setting->logo) }}">
<i id="remove-logo-img" class="fa fa-times remove-logo" data-id="logo" aria-hidden="true"></i> <i id="remove-logo-img" class="fa fa-times remove-logo" data-id="logo" aria-hidden="true"></i>
@endif @endif
</div> </div>
......
...@@ -3,18 +3,202 @@ ...@@ -3,18 +3,202 @@
namespace Tests\Feature\Backend; namespace Tests\Feature\Backend;
use Tests\TestCase; use Tests\TestCase;
use App\Models\Blogs\Blog;
use App\Models\BlogTags\BlogTag;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use App\Models\BlogCategories\BlogCategory;
use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\RefreshDatabase;
class ManageBlogsTest extends TestCase class ManageBlogsTest extends TestCase
{ {
/** use WithFaker;
* A basic test example.
* protected $blog;
* @return void protected $categories;
*/ protected $tags;
public function testExample()
{ public function setUp()
$this->assertTrue(true); {
parent::setUp();
$this->actingAs($this->admin);
$this->blog = create(Blog::class);
$this->categories = [$this->faker->word, $this->faker->word];
$this->tags = [$this->faker->word, $this->faker->word];
}
/** @test */
public function a_user_can_view_blogs_index_page()
{
$this->actingAs($this->admin)
->get(route('admin.blogs.index'))
->assertViewIs('backend.blogs.index')
->assertSee(trans('labels.backend.blogs.management'))
->assertSee(trans('labels.backend.blogs.table.title'))
->assertSee(trans('labels.backend.blogs.table.publish'))
->assertSee(trans('labels.backend.blogs.table.createdby'))
->assertSee(trans('labels.backend.blogs.table.createdat'))
->assertSee(trans('labels.backend.blogs.table.status'))
->assertSee('Export')
->assertSee('Action');
}
/** @test */
public function a_user_can_create_a_blog()
{
$blog = make(Blog::class, [
'featured_image' => UploadedFile::fake()->image('logo.jpg'),
'categories' => $this->categories,
'tags' => $this->tags
]);
$this->post(route('admin.blogs.store'), $blog->toArray());
$this->assertDatabaseHas(config('module.blogs.table'), ['name' => $blog->name, 'status' => $blog->status]);
//Assert Tags have been saved
$this->assertDatabaseHas(config('module.blog_tags.table'), ['name' => $this->tags[0]]);
$this->assertDatabaseHas(config('module.blog_tags.table'), ['name' => $this->tags[1]]);
//Assert Categories have been saved
$this->assertDatabaseHas(config('module.blog_categories.table'), ['name' => $this->categories[0]]);
$this->assertDatabaseHas(config('module.blog_categories.table'), ['name' => $this->categories[1]]);
}
public function makeBlog($overrides = [])
{
$this->withExceptionHandling();
$blog = make(Blog::class, $overrides);
return $blog;
}
/** @test */
public function it_requires_name_while_creating()
{
$blog = $this->makeBlog(['name' => '']);
$this->post(route('admin.blogs.store'), $blog->toArray())
->assertSessionHasErrors('name');
}
/** @test */
public function it_requires_content_while_creating()
{
$blog = $this->makeBlog(['content' => '']);
$this->post(route('admin.blogs.store'), $blog->toArray())
->assertSessionHasErrors('content');
}
/** @test */
public function it_requires_featured_image_while_creating()
{
$blog = $this->makeBlog(['featured_image' => '']);
$this->post(route('admin.blogs.store'), $blog->toArray())
->assertSessionHasErrors('featured_image');
}
/** @test */
public function it_requires_categories_while_creating()
{
$blog = $this->makeBlog(['categories' => '']);
$this->post(route('admin.blogs.store'), $blog->toArray())
->assertSessionHasErrors('categories');
}
/** @test */
public function it_requires_tags_while_creating()
{
$blog = $this->makeBlog(['tags' => '']);
$this->post(route('admin.blogs.store'), $blog->toArray())
->assertSessionHasErrors('tags');
}
/** @test */
public function it_can_store_featured_image()
{
$blog = make(Blog::class, [
'featured_image' => UploadedFile::fake()->image('logo.jpg'),
'categories' => $this->categories,
'tags' => $this->tags
]);
$this->post(route('admin.blogs.store'), $blog->toArray());
$stored_blog = Blog::find(2);
Storage::disk('public')->assertExists('img/blog/' . $stored_blog->featured_image);
}
/** @test */
public function it_requires_name_while_updating()
{
$this->withExceptionHandling();
$this->blog->name = '';
$this->patch(route('admin.blogs.update', $this->blog), $this->blog->toArray())
->assertSessionHasErrors('name');
}
/** @test */
public function it_requires_content_while_updating()
{
$this->withExceptionHandling();
$this->blog->content = '';
$this->patch(route('admin.blogs.update', $this->blog), $this->blog->toArray())
->assertSessionHasErrors('content');
}
/** @test */
public function it_requires_categories_while_updating()
{
$this->withExceptionHandling();
$this->patch(route('admin.blogs.update', $this->blog), $this->blog->toArray())
->assertSessionHasErrors('categories');
}
/** @test */
public function it_requires_tags_while_updating()
{
$this->withExceptionHandling();
$this->patch(route('admin.blogs.update', $this->blog), $this->blog->toArray())
->assertSessionHasErrors('tags');
}
/** @test */
public function a_user_can_update_blog()
{
$blog = make(Blog::class, [
'featured_image' => UploadedFile::fake()->image('logo.jpg'),
'name' => 'Changed Name',
'categories' => $this->categories,
'tags' => $this->tags
]);
$this->patch(route('admin.blogs.update', $this->blog), $blog->toArray());
$this->assertDatabaseHas(config('module.blogs.table'), ['id' => $this->blog->id, 'name' => 'Changed Name']);
}
/** @test */
public function a_user_can_delete_a_blog()
{
$this->delete(route('admin.blogs.destroy', $this->blog));
$this->assertDatabaseMissing(config('module.blogs.table'), ['id' => $this->blog->id, 'deleted_at' => null]);
} }
} }
...@@ -57,22 +57,19 @@ class ManagePagesTest extends TestCase ...@@ -57,22 +57,19 @@ class ManagePagesTest extends TestCase
} }
/** @test */ /** @test */
public function it_fails_for_validation_on_create_page() public function it_requires_title_on_create()
{ {
$page = make(Page::class, ['title' => '', 'description' => '']);
$this->withExceptionHandling()
->actingAs($this->admin)
->post(route('admin.pages.store'), $page->toArray())
->assertSessionHasErrors(['title', 'description']);
$page = make(Page::class, ['title' => '']); $page = make(Page::class, ['title' => '']);
$this->withExceptionHandling() $this->withExceptionHandling()
->actingAs($this->admin) ->actingAs($this->admin)
->post(route('admin.pages.store'), $page->toArray()) ->post(route('admin.pages.store'), $page->toArray())
->assertSessionHasErrors('title'); ->assertSessionHasErrors('title');
}
/** @test */
public function it_requires_description_while_create()
{
$page = make(Page::class, ['description' => '']); $page = make(Page::class, ['description' => '']);
$this->withExceptionHandling() $this->withExceptionHandling()
...@@ -96,32 +93,32 @@ class ManagePagesTest extends TestCase ...@@ -96,32 +93,32 @@ class ManagePagesTest extends TestCase
} }
/** @test */ /** @test */
public function it_fails_for_validation_on_update() public function it_requires_title_on_update()
{ {
$page = create(Page::class); $page = create(Page::class);
$page1 = $page2 = $page3 = $page->toArray(); $page1 = $page->toArray();
$page1['title'] = ''; $page1['title'] = '';
$page1['description'] = '';
$this->withExceptionHandling() $this->withExceptionHandling()
->actingAs($this->admin) ->actingAs($this->admin)
->post(route('admin.pages.store'), $page1) ->patch(route('admin.pages.update', $page), $page1)
->assertSessionHasErrors(['title', 'description']); ->assertSessionHasErrors('title');
}
$page2['title'] = ''; /** @test */
public function it_requires_description_while_update()
{
$page = create(Page::class);
$this->withExceptionHandling() $page1 = $page->toArray();
->actingAs($this->admin)
->post(route('admin.pages.store'), $page2)
->assertSessionHasErrors('title');
$page3['description'] = ''; $page1['description'] = '';
$this->withExceptionHandling() $this->withExceptionHandling()
->actingAs($this->admin) ->actingAs($this->admin)
->post(route('admin.pages.store'), $page3) ->patch(route('admin.pages.update', $page), $page1)
->assertSessionHasErrors('description'); ->assertSessionHasErrors('description');
} }
......
...@@ -55,7 +55,7 @@ class BlogTest extends TestCase ...@@ -55,7 +55,7 @@ class BlogTest extends TestCase
} }
/** @test */ /** @test */
public function it_has_a_date_field_for_publish_datetime() public function it_has_a_carbon_date_field_for_publish_datetime()
{ {
$this->actingAs($this->admin); $this->actingAs($this->admin);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment