Skip to content

Commit

Permalink
Merge pull request #9 from bjuppa/travis
Browse files Browse the repository at this point in the history
Setup Travis CI
  • Loading branch information
bjuppa authored Aug 17, 2019
2 parents 4b6c46a + 960f867 commit 96d4408
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 10 deletions.
34 changes: 34 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
cache:
directories:
- $HOME/.composer/cache

language: php

matrix:
include:
- php: 7.1
env: LARAVEL='5.7.*'
- php: 7.2
env: LARAVEL='5.7.*'
- php: 7.2
env: LARAVEL='5.8.*'
- php: 7.3
env: LARAVEL='5.7.*'
- php: 7.3
env: LARAVEL='5.8.*'
fast_finish: true

before_install:
- travis_retry composer self-update
- travis_retry composer require "laravel/framework:${LARAVEL}" --no-interaction --no-update

install:
- travis_retry composer install --prefer-dist --no-interaction --no-suggest

before_script:
- if [[ $COVERAGE == "" ]]; then phpenv config-rm xdebug.ini; fi
- composer config discard-changes true

script:
- vendor/bin/phpcs
- vendor/bin/phpunit
12 changes: 12 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,24 @@ Logs created during test runs can be found in `vendor/orchestra/testbench-core/l
If you want your own local configuration for phpunit,
copy the file `phpunit.xml.dist` to `phpunit.xml` and modify the latter to your needs.

## Following PSR2

This project can be checked against configured coding standards using `composer phpcs` from the project directory.

Automatic attempt to fix some reported coding standard violations can be run with
`./vendor/bin/phpcbf` from the project directory.

## Dependency version testing

- `composer update --prefer-lowest` can be used before running tests for testing backwards compatibility.
- `composer show -D -o` can be used to check how far behind latest version the currently installed dependencies are.
- `composer update` will install the latest versions of dependencies.

## Continuous integration

[Travis CI](https://travis-ci.org/bjuppa/laravel-blog-admin) is set up to run tests on multiple versions of PHP and Laravel
whenever a git push or a PR is made.

## Compiled views

Running `composer clearCompiledViews` will delete the contents of
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# laravel-blog-admin

[![Build Status](https://travis-ci.org/bjuppa/laravel-blog-admin.svg?branch=master)](https://travis-ci.org/bjuppa/laravel-blog-admin)

Optional admin interface for [bjuppa/laravel-blog](https://packagist.org/packages/bjuppa/laravel-blog).

The admin pages of this packge depend on [kontenta/kontour](https://packagist.org/packages/kontenta/kontour),
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
},
"require-dev": {
"orchestra/testbench": "~3.6",
"laravel/framework": ">=5.6.25",
"phpunit/phpunit": ">6.5",
"mockery/mockery": "^1.0",
"andrefigueira/blog-article-faker": "^1.0"
"andrefigueira/blog-article-faker": "^1.0",
"squizlabs/php_codesniffer": "^3.4"
},
"autoload": {
"psr-4": {
Expand All @@ -39,6 +39,7 @@
"scripts": {
"test": "vendor/bin/phpunit",
"report": "@test --coverage-html build/coverage --coverage-text=build/coverage.txt",
"phpcs": "vendor/bin/phpcs",
"post-update-cmd": "@clearCompiledViews",
"clearCompiledViews": "rm -f vendor/orchestra/testbench-core/laravel/storage/framework/views/*"
},
Expand Down
8 changes: 8 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<ruleset name="PSR2">
<description>The PSR2 coding standard.</description>
<rule ref="PSR2"/>
<file>config</file>
<file>routes</file>
<file>src</file>
</ruleset>
2 changes: 1 addition & 1 deletion routes/blog-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use Illuminate\Support\Facades\Route;

Route::namespace ('Bjuppa\LaravelBlogAdmin\Http\Controllers')->name('blog-admin.')->group(function () {
Route::namespace('Bjuppa\LaravelBlogAdmin\Http\Controllers')->name('blog-admin.')->group(function () {
Route::get('/blogs/{blog}', 'BlogController@show')->name('blogs.show');
Route::get('/blogs/{blog}/entries/create', 'BlogEntryController@create')->name('entries.create');
Route::post('/blog-entries', 'BlogEntryController@store')->name('entries.store');
Expand Down
4 changes: 3 additions & 1 deletion src/Http/Controllers/BlogEntryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ public function destroy(BlogEntryRequest $request)

protected function buildCrumbtrail(Blog $blog, $currentPageName)
{
$this->crumbtrail->addLink(AdminLink::create($blog->getTitle(), route('blog-admin.blogs.show', $blog->getId())));
$this->crumbtrail->addLink(
AdminLink::create($blog->getTitle(), route('blog-admin.blogs.show', $blog->getId()))
);
$this->crumbtrail->addLink(AdminLink::create($currentPageName, url()->current()));
}

Expand Down
12 changes: 6 additions & 6 deletions src/Http/Requests/BlogEntryRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@ public function ensureRequestHasBlogAndEntryInstances()
if (!$this->blog) {
abort(Response::HTTP_NOT_FOUND, 'Blog "' . e($this->blog) . '" does not exist');
}
abort_unless($this->blog->getEntryProvider() instanceof \Bjuppa\LaravelBlog\Eloquent\BlogEntryProvider,
abort_unless(
$this->blog->getEntryProvider() instanceof \Bjuppa\LaravelBlog\Eloquent\BlogEntryProvider,
Response::HTTP_INTERNAL_SERVER_ERROR,
'Blog "' . e($this->blog->getId()) . '" is not configured with the Eloquent entry provider'
);

if (!$this->entry instanceof BlogEntry) {
$this->entry = (
$this->blog->getEntryProvider()->getBlogEntryModel()->withUnpublished()->find($this->entry) ??
$this->blog->getEntryProvider()->getBlogEntryModel()
);
$this->entry =
$this->blog->getEntryProvider()->getBlogEntryModel()->withUnpublished()->find($this->entry)
?? $this->blog->getEntryProvider()->getBlogEntryModel();
}

abort_if($this->isMethod('PATCH') and !$this->entry->exists, Response::HTTP_METHOD_NOT_ALLOWED);
Expand All @@ -113,7 +113,7 @@ public function getValidBlogsForCurrentUser()
{
return $this->blogRegistry->all()->filter(function ($blog) {
return $this->user()->can($blog->getCreateAbility(), $blog->getId())
and $blog->getEntryProvider() instanceof \Bjuppa\LaravelBlog\Eloquent\BlogEntryProvider;
and $blog->getEntryProvider() instanceof \Bjuppa\LaravelBlog\Eloquent\BlogEntryProvider;
});
}
}

0 comments on commit 96d4408

Please sign in to comment.