Unverified Commit 1b867e39 authored by Viral Solani's avatar Viral Solani Committed by GitHub

Merge pull request #139 from viralsolani/analysis-qyL1yb

Apply fixes from StyleCI
parents 55b49b3a 14fbfac5
......@@ -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]);
......@@ -248,6 +247,6 @@ class BlogsRepository extends BaseRepository
{
$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 [
......@@ -18,10 +17,9 @@ $factory->define(Blog::class, function (Faker $faker) {
'publish_datetime' => $faker->dateTime(),
'featured_image' => 'logo.png',
'content' => $faker->paragraph(3),
'status' => $status[$faker->numberBetween(0,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;
......
......@@ -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 */
......@@ -52,7 +49,7 @@ class ManageBlogsTest extends TestCase
$blog = make(Blog::class, [
'featured_image' => UploadedFile::fake()->image('logo.jpg'),
'categories' => $this->categories,
'tags' => $this->tags
'tags' => $this->tags,
]);
$this->post(route('admin.blogs.store'), $blog->toArray());
......@@ -128,14 +125,14 @@ class ManageBlogsTest extends TestCase
$blog = make(Blog::class, [
'featured_image' => UploadedFile::fake()->image('logo.jpg'),
'categories' => $this->categories,
'tags' => $this->tags
'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 */
......@@ -185,7 +182,7 @@ class ManageBlogsTest extends TestCase
'featured_image' => UploadedFile::fake()->image('logo.jpg'),
'name' => 'Changed Name',
'categories' => $this->categories,
'tags' => $this->tags
'tags' => $this->tags,
]);
$this->patch(route('admin.blogs.update', $this->blog), $blog->toArray());
......
......@@ -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,7 +20,7 @@ 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());
......@@ -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