Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-adminpanel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
laravel-adminpanel
Commits
1b867e39
Unverified
Commit
1b867e39
authored
Jan 08, 2018
by
Viral Solani
Committed by
GitHub
Jan 08, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #139 from viralsolani/analysis-qyL1yb
Apply fixes from StyleCI
parents
55b49b3a
14fbfac5
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
53 additions
and
61 deletions
+53
-61
BlogsRepository.php
app/Repositories/Backend/Blogs/BlogsRepository.php
+14
-15
BlogFactory.php
database/factories/BlogFactory.php
+8
-10
FaqFactory.php
database/factories/FaqFactory.php
+2
-2
PageFactory.php
database/factories/PageFactory.php
+2
-2
ManageBlogsTest.php
tests/Feature/Backend/ManageBlogsTest.php
+17
-20
ManageFaqsTest.php
tests/Feature/Backend/ManageFaqsTest.php
+3
-4
BlogTest.php
tests/Unit/Models/BlogTest.php
+7
-8
No files found.
app/Repositories/Backend/Blogs/BlogsRepository.php
View file @
1b867e39
...
...
@@ -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\E
vents\Backend\Blogs\BlogCreated
;
use
App\E
xceptions\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
);
}
}
database/factories/BlogFactory.php
View file @
1b867e39
<?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
;
},
];
});
database/factories/FaqFactory.php
View file @
1b867e39
...
...
@@ -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
),
];
});
database/factories/PageFactory.php
View file @
1b867e39
<?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
;
...
...
tests/Feature/Backend/ManageBlogsTest.php
View file @
1b867e39
...
...
@@ -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
());
...
...
tests/Feature/Backend/ManageFaqsTest.php
View file @
1b867e39
...
...
@@ -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
]);
}
...
...
tests/Unit/Models/BlogTest.php
View file @
1b867e39
...
...
@@ -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
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment