Commit 14fbfac5 authored by Viral Solani's avatar Viral Solani Committed by StyleCI Bot

Apply fixes from StyleCI

parent 55b49b3a
......@@ -2,20 +2,19 @@
namespace App\Repositories\Backend\Blogs;
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\BlogCreated;
use App\Events\Backend\Blogs\BlogDeleted;
use App\Events\Backend\Blogs\BlogUpdated;
use App\Events\Backend\Blogs\BlogCreated;
use App\Exceptions\GeneralException;
use App\Models\BlogCategories\BlogCategory;
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;
use Illuminate\Support\Facades\Storage;
/**
* Class BlogsRepository.
......@@ -38,7 +37,7 @@ class BlogsRepository extends BaseRepository
public function __construct()
{
$this->upload_path = 'img' . DIRECTORY_SEPARATOR . 'blog' . DIRECTORY_SEPARATOR;
$this->upload_path = 'img'.DIRECTORY_SEPARATOR.'blog'.DIRECTORY_SEPARATOR;
$this->storage = Storage::disk('public');
}
......@@ -229,9 +228,9 @@ class BlogsRepository extends BaseRepository
$avatar = $input['featured_image'];
if (isset($input['featured_image']) && !empty($input['featured_image'])) {
$fileName = time() . $avatar->getClientOriginalName();
$fileName = time().$avatar->getClientOriginalName();
$this->storage->put($this->upload_path . $fileName, file_get_contents($avatar->getRealPath()));
$this->storage->put($this->upload_path.$fileName, file_get_contents($avatar->getRealPath()));
$input = array_merge($input, ['featured_image' => $fileName]);
......@@ -247,7 +246,7 @@ class BlogsRepository extends BaseRepository
public function deleteOldFile($model)
{
$fileName = $model->featured_image;
return $this->storage->delete($this->upload_path . $fileName);
return $this->storage->delete($this->upload_path.$fileName);
}
}
<?php
use App\Models\Access\User\User;
use App\Models\Blogs\Blog;
use Faker\Generator as Faker;
use App\Models\Access\User\User;
$factory->define(Blog::class, function (Faker $faker) {
$status = [
'Published',
'Draft',
'InActive',
'Scheduled'
'Scheduled',
];
return [
'name' => $faker->sentence,
'name' => $faker->sentence,
'publish_datetime' => $faker->dateTime(),
'featured_image' => 'logo.png',
'content' => $faker->paragraph(3),
'status' => $status[$faker->numberBetween(0,3)],
'created_by' => function () {
'featured_image' => 'logo.png',
'content' => $faker->paragraph(3),
'status' => $status[$faker->numberBetween(0, 3)],
'created_by' => function () {
return factory(User::class)->create()->id;
},
];
});
......@@ -5,8 +5,8 @@ use Faker\Generator as Faker;
$factory->define(Faq::class, function (Faker $faker) {
return [
'question' => rtrim($faker->sentence, '.') . '?',
'question' => rtrim($faker->sentence, '.').'?',
'answer' => $faker->paragraph,
'status' => $faker->numberBetween(0,1)
'status' => $faker->numberBetween(0, 1),
];
});
<?php
use App\Models\Access\User\User;
use App\Models\Page\Page;
use Faker\Generator as Faker;
use App\Models\Access\User\User;
$factory->define(Page::class, function (Faker $faker) {
$title = $faker->sentence;
......@@ -11,7 +11,7 @@ $factory->define(Page::class, function (Faker $faker) {
'title' => $title,
'page_slug' => str_slug($title),
'description' => $faker->paragraph,
'created_by' => function () {
'created_by' => function () {
return factory(User::class)->create()->id;
},
];
......
......@@ -2,13 +2,11 @@
namespace Tests\Feature\Backend;
use Tests\TestCase;
use App\Models\Blogs\Blog;
use App\Models\BlogTags\BlogTag;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use App\Models\BlogCategories\BlogCategory;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class ManageBlogsTest extends TestCase
{
......@@ -27,7 +25,6 @@ class ManageBlogsTest extends TestCase
$this->blog = create(Blog::class);
$this->categories = [$this->faker->word, $this->faker->word];
$this->tags = [$this->faker->word, $this->faker->word];
}
/** @test */
......@@ -48,21 +45,21 @@ class ManageBlogsTest extends TestCase
/** @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
'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]]);
......@@ -108,7 +105,7 @@ class ManageBlogsTest extends TestCase
public function it_requires_categories_while_creating()
{
$blog = $this->makeBlog(['categories' => '']);
$this->post(route('admin.blogs.store'), $blog->toArray())
->assertSessionHasErrors('categories');
}
......@@ -127,15 +124,15 @@ class ManageBlogsTest extends TestCase
{
$blog = make(Blog::class, [
'featured_image' => UploadedFile::fake()->image('logo.jpg'),
'categories' => $this->categories,
'tags' => $this->tags
'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);
Storage::disk('public')->assertExists('img/blog/'.$stored_blog->featured_image);
}
/** @test */
......@@ -159,7 +156,7 @@ class ManageBlogsTest extends TestCase
$this->patch(route('admin.blogs.update', $this->blog), $this->blog->toArray())
->assertSessionHasErrors('content');
}
/** @test */
public function it_requires_categories_while_updating()
{
......@@ -182,17 +179,17 @@ class ManageBlogsTest extends TestCase
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
'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()
{
......
......@@ -2,8 +2,8 @@
namespace Tests\Feature\Backend;
use Tests\TestCase;
use App\Models\Faqs\Faq;
use Tests\TestCase;
class ManageFaqsTest extends TestCase
{
......@@ -43,7 +43,6 @@ class ManageFaqsTest extends TestCase
->assertSessionHasErrors('question');
}
/** @test */
public function it_requires_answer_while_creating()
{
......@@ -82,7 +81,7 @@ class ManageFaqsTest extends TestCase
{
$faq = create(Faq::class);
$changed_question = "What is Life?";
$changed_question = 'What is Life?';
$changed_answer = $faq->answer;
$this->actingAs($this->admin)
->patch(route('admin.faqs.update', $faq), ['question' => $changed_question, 'answer' => $changed_answer]);
......@@ -96,7 +95,7 @@ class ManageFaqsTest extends TestCase
$faq = create(Faq::class);
$this->actingAs($this->admin)
->delete(route('admin.faqs.destroy' , $faq));
->delete(route('admin.faqs.destroy', $faq));
$this->assertDatabaseMissing(config('module.faqs.table'), ['id' => $faq->id, 'deleted_at' => null]);
}
......
......@@ -2,13 +2,12 @@
namespace Tests\Unit\Models;
use Carbon\Carbon;
use Tests\TestCase;
use App\Models\Blogs\Blog;
use App\Models\BlogTags\BlogTag;
use App\Models\Access\User\User;
use App\Models\BlogCategories\BlogCategory;
use Illuminate\Foundation\Testing\WithFaker;
use App\Models\Blogs\Blog;
use App\Models\BlogTags\BlogTag;
use Carbon\Carbon;
use Tests\TestCase;
class BlogTest extends TestCase
{
......@@ -21,8 +20,8 @@ class BlogTest extends TestCase
$category = create(BlogCategory::class);
$blog->categories()->sync(array($category->id));
$blog->categories()->sync([$category->id]);
$this->assertInstanceOf(BlogCategory::class, $blog->categories->first());
$this->assertEquals($category->id, $blog->categories->first()->id);
......@@ -37,7 +36,7 @@ class BlogTest extends TestCase
$tag = create(BlogTag::class);
$blog->tags()->sync(array($tag->id));
$blog->tags()->sync([$tag->id]);
$this->assertInstanceOf(BlogTag::class, $blog->tags->first());
......
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