Skip to content

Commit

Permalink
Merge pull request #60 from bearsunday/refactor
Browse files Browse the repository at this point in the history
Refactor & Add travis CI
  • Loading branch information
koriym authored Mar 18, 2018
2 parents d211e8c + 36f423b commit 6c870cb
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ return \PhpCsFixer\Config::create()
'whitespace_after_comma_in_array' => true
))
->setLineEnding("\n")
->setUsingCache(false)
->setUsingCache(true)
->setFinder(
PhpCsFixer\Finder::create()
->exclude('var')
Expand Down
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
language: php
sudo: false
php:
- 7
- 7.1
- 7.2
cache:
directories:
- vendor
- $HOME/.composer/cache
env:
matrix:
- DEPENDENCIES=''
- DEPENDENCIES='--prefer-lowest --prefer-stable'
before_script:
- composer self-update
- composer update --no-interaction $DEPENDENCIES
- composer dump-autoload
- if [[ $TRAVIS_PHP_VERSION = '7.1' && DEPENDENCIES = '' ]]; then COVERAGE="--coverage-clover=coverage.clover"; else phpenv config-rm xdebug.ini; fi
- if [[ $TRAVIS_PHP_VERSION = '7.1' && DEPENDENCIES = '' ]]; then composer require --dev phpstan/phpstan-shim friendsofphp/php-cs-fixer; fi
script:
- php bootstrap/web.php get /
- ./vendor/bin/phpunit $COVERAGE;
- if [[ $TRAVIS_PHP_VERSION = '7.1' && DEPENDENCIES = '' ]]; then IFS=$'\n'; COMMIT_SCA_FILES=($(git diff --name-only --diff-filter=ACMRTUXB "${TRAVIS_COMMIT_RANGE}")); unset IFS && ./vendor/bin/php-cs-fixer fix --config=.php_cs -v --dry-run --stop-on-violation --using-cache=no --path-mode=intersection -- "${COMMIT_SCA_FILES[@]}";fi
- if [[ $TRAVIS_PHP_VERSION = '7.1' && DEPENDENCIES = '' ]]; then ./vendor/bin/phpstan analyse -l max -c phpstan.neon src tests --no-progress --no-interaction; fi
after_script:
- if [[ $TRAVIS_PHP_VERSION = '7.1' ]]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# BEAR.Skeleton

[![Build Status](https://travis-ci.org/bearsunday/BEAR.Skeleton.svg?branch=1.x)](https://travis-ci.org/bearsunday/BEAR.Skeleton)

This is a skeleton app which can be used a base for your own BEAR.Sunday applications.

The documentation available at http://bearsunday.github.io/
3 changes: 2 additions & 1 deletion bootstrap/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
use BEAR\Package\Bootstrap;
use BEAR\Resource\ResourceObject;

require dirname(__DIR__) . '/vendor/autoload.php';

Expand All @@ -8,7 +9,7 @@
$request = $app->router->match($GLOBALS, $_SERVER);
try {
$page = $app->resource->{$request->method}->uri($request->path)($request->query);
/* @var $page \BEAR\Resource\ResourceObject */
/* @var ResourceObject $page */
$page->transfer($app->responder, $_SERVER);
exit(0);
} catch (\Exception $e) {
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"license":"MIT",
"description": "Skeleton application for BEAR.Sunday",
"require": {
"php": "^7.0",
"roave/security-advisories": "dev-master",
"bear/package": "^1.5",
"josegonzalez/dotenv": "^2.1"
"php": ">=7.0.0",
"roave/security-advisories": "dev-master",
"bear/package": "^1.7.2",
"josegonzalez/dotenv": "^3.2"
},
"require-dev": {
"bear/qatools": "^1.4.9"
Expand All @@ -27,7 +27,7 @@
"post-create-project-cmd": [
"composer dump-autoload"
],
"test": ["phpunit"],
"test": ["phpunit", "@cs"],
"coverage": ["php -dzend_extension=xdebug.so ./vendor/bin/phpunit --coverage-text --coverage-html=build/coverage"],
"cs": ["php-cs-fixer fix -v --dry-run", "phpcs --standard=./phpcs.xml src"],
"cs-fix": ["php-cs-fixer fix -v", "phpcbf src"],
Expand Down
Binary file modified public/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions src/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ final class Composer
public static function install(Event $event)
{
(new Install)($event);
unlink(dirname(__DIR__) . '/.travis.yml');
unlink(__FILE__);
}
}
7 changes: 2 additions & 5 deletions src/Module/AppModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace BEAR\Skeleton\Module;

use BEAR\Package\PackageModule;
use josegonzalez\Dotenv\Loader as Dotenv;
use josegonzalez\Dotenv\Loader;
use Ray\Di\AbstractModule;

class AppModule extends AbstractModule
Expand All @@ -13,10 +13,7 @@ class AppModule extends AbstractModule
protected function configure()
{
$appDir = dirname(__DIR__, 2);
Dotenv::load([
'filepath' => $appDir . '/.env',
'toEnv' => true
]);
(new Loader($appDir . '/.env'))->parse()->toEnv();
$this->install(new PackageModule);
}
}
28 changes: 0 additions & 28 deletions tests/Module/ModuleTest.php

This file was deleted.

Empty file removed tests/Resource/App/.placefolder
Empty file.
2 changes: 1 addition & 1 deletion tests/Resource/Page/IndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected function setUp()
public function testOnGet()
{
$ro = $this->resource->uri('page://self/index')(['name' => 'BEAR.Sunday']);
/* @var $ro Index */
/* @var Index $ro */
$this->assertSame(200, $ro->code);
$this->assertSame('Hello BEAR.Sunday', $ro['greeting']);

Expand Down

0 comments on commit 6c870cb

Please sign in to comment.