Skip to content

Commit

Permalink
trying to fix travis
Browse files Browse the repository at this point in the history
  • Loading branch information
REBELinBLUE committed Feb 17, 2017
1 parent c10d35e commit ea87dc7
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 34 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ install:
- travis_retry npm install --quiet

before_script:
- mkdir $TRAVIS_BUILD_DIR/tmp/
- make ci
- gulp
# - php artisan js-localization:refresh
Expand All @@ -86,7 +87,9 @@ script:
- make rollback
- make phpcs
# - make phpmd
- make phpunit-ci
- make phpunit-ci-step1
- make phpunit-ci-step2
- make phpunit-ci-step3
- make phpdoc-check
- make phpcpd
- make lines
Expand All @@ -97,6 +100,7 @@ script:
- php artisan app:version

after_script:
- rm -rf $TRAVIS_BUILD_DIR/tmp/
- find $TRAVIS_BUILD_DIR/storage/logs/*.log -type f -print -exec cat {} \;
- cat $TRAVIS_BUILD_DIR/.env

Expand Down
29 changes: 16 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
.SILENT:

build: ##@development Frontend build
build: install-dev localise
build: install-dev
@-rm -rf public/build
#@php artisan js-localization:export
gulp
@rm -rf public/css public/fonts public/js

Expand Down Expand Up @@ -35,9 +36,6 @@ lines: ##@tests PHP Lines of Code
@echo "\033[32mLines of Code Statistics\033[39m"
@php vendor/bin/phploc --count-tests app/ database/ resources/ tests/

localise: ##@production Runs the artisan js localisation refresh command
@php artisan js-localization:refresh

migrate: ##@production Migrate the database
@echo "\033[32mMigrate the database\033[39m"
@php artisan migrate
Expand Down Expand Up @@ -149,25 +147,30 @@ else
endif

# Run the PHPUnit tests for Travis CI
phpunit-ci:
phpunit-ci-step1:
ifeq "$(TRAVIS_PHP_VERSION)" "7.0"
@mkdir tmp/
@echo "\033[32mFast Unit Tests with coverage\033[39m"
@php vendor/bin/phpunit --coverage-php=tmp/unit.cov --testsuite "Unit Tests" --exclude-group slow
@echo "\033[32mSlow Unit Tests with coverage\033[39m"
@php vendor/bin/phpunit --coverage-php=tmp/slow.cov --testsuite "Unit Tests" --exclude-group default
@echo "\033[32mIntegration Tests with coverage\033[39m"
@php vendor/bin/phpunit --coverage-php=tmp/integration.cov --testsuite "Integration Tests"
@echo "\033[32mMerging coverage\033[39m"
@php vendor/bin/phpcov merge tmp/ --clover coverage.xml
@rm -rf tmp/
else ifeq "$(DB)" "sqlite"
@$(MAKE) phpunit
@$(MAKE) integration
else
@$(MAKE) phpunit-fast
endif

phpunit-ci-step2:
ifeq "$(TRAVIS_PHP_VERSION)" "7.0"
@echo "\033[32mSlow Unit Tests with coverage\033[39m"
@php vendor/bin/phpunit --coverage-php=tmp/slow.cov --testsuite "Unit Tests" --exclude-group default
endif

phpunit-ci-step3:
ifeq "$(TRAVIS_PHP_VERSION)" "7.0"
@php vendor/bin/phpunit --coverage-php=tmp/integration.cov --testsuite "Integration Tests"
@echo "\033[32mMerging coverage\033[39m"
@php vendor/bin/phpcov merge tmp/ --clover coverage.xml
endif

# Create release
release: test
@/usr/local/bin/create-release
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/CreateUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Console\Command;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Validation\Factory;
use Illuminate\Contracts\Validation\Factory;
use REBELinBLUE\Deployer\Events\UserWasCreated;
use REBELinBLUE\Deployer\Repositories\Contracts\UserRepositoryInterface;
use REBELinBLUE\Deployer\Services\Token\TokenGeneratorInterface;
Expand Down Expand Up @@ -56,7 +56,7 @@ public function __construct(UserRepositoryInterface $repository)
* Execute the console command.
*
* @param Dispatcher $dispatcher
* @param Factory $validation
* @param Factory $validation
*/
public function handle(Dispatcher $dispatcher, Factory $validation, TokenGeneratorInterface $generator)
{
Expand Down
6 changes: 2 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"([ -f .env ] && [ -n \"$TRAVIS\" ] && sed -i 's/DB_TYPE=/DB_CONNECTION=/g' .env) || exit 0",
"([ -f .env ] && [ -n \"$TRAVIS\" ] && php artisan optimize) || exit 0",
"([ -f .env ] && [ -n \"$TRAVIS\" ] && php artisan js-localization:refresh) || exit 0"
"([ -f .env ] && [ -n \"$TRAVIS\" ] && php artisan optimize) || exit 0"
],
"pre-update-cmd": [
"php artisan clear-compiled"
Expand All @@ -100,8 +99,7 @@
"php artisan ide-helper:generate",
"php artisan ide-helper:meta",
"php artisan ide-helper:models --nowrite",
"php artisan optimize",
"php artisan js-localization:refresh"
"php artisan optimize"
]
},
"extra": {
Expand Down
10 changes: 10 additions & 0 deletions config/js-localization.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@

'locales' => ['en', 'zh'],

/*
|--------------------------------------------------------------------------
| Define the target to save the exported messages to
|--------------------------------------------------------------------------
|
| Directory for storing the static files generated when using file storage.
|
*/
'storage_path' => public_path('/'),

/*
|--------------------------------------------------------------------------
| Define the messages to export
Expand Down
1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const shell = require('gulp-shell');
const bower = require('gulp-bower');
require('laravel-elixir-remove');

// FIXME: Change to generate the localised file! with php artisan js-localization:export
// Elixir.extend('lang', function () {
// new Elixir.Task('lang', function () {
// return gulp.src('').pipe(shell('php artisan js-localization:refresh'));
Expand Down
52 changes: 38 additions & 14 deletions tests/Unit/Console/Commands/CreateUserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Validation\Factory;
use Illuminate\Foundation\Application;
use Mockery as m;
use REBELinBLUE\Deployer\Console\Commands\CreateUser;
use REBELinBLUE\Deployer\Repositories\Contracts\UserRepositoryInterface;
use REBELinBLUE\Deployer\Services\Token\TokenGeneratorInterface;
use REBELinBLUE\Deployer\Tests\TestCase;
use REBELinBLUE\Deployer\Console\Commands\CreateUser;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;

/**
* @coversDefaultClass \REBELinBLUE\Deployer\Console\Commands\CreateUser
Expand Down Expand Up @@ -40,17 +43,37 @@ public function setUp()
parent::setUp();

$repository = m::mock(UserRepositoryInterface::class);

$dispatcher = m::mock(Dispatcher::class);

$validation = m::mock(Factory::class);
$generator = m::mock(TokenGeneratorInterface::class);

$app = new Application();

// $app->bind('validator', function () {
// return m::mock(Factory::class);
// });

$app->bind(TokenGeneratorInterface::class, function () use (&$generator) {
return $generator;
});

$generator = m::mock(TokenGeneratorInterface::class);
$app->bind(Factory::class, function () use (&$validation) {
return $validation;
});

$app->bind(Dispatcher::class, function () use (&$dispatcher) {
return $dispatcher;
});

$app->bind(UserRepositoryInterface::class, function () use (&$repository) {
return $repository;
});

$this->repository = $repository;
$this->dispatcher = $dispatcher;
$this->validation = $validation;
$this->generator = $generator;
$this->generator = $generator;
$this->app = $app;
}

/**
Expand All @@ -59,18 +82,19 @@ public function setUp()
*/
public function testHandle()
{
$this->markTestIncomplete('not yet done');
// see https://github.com/laravel/framework/blob/5.4/tests/Database/DatabaseMigrationMakeCommandTest.php
$name = 'Jill';
$email = 'jill@example.com';

$this->markTestIncomplete('not working');

$console = new CreateUser($this->repository);
// $console->addArgument('name', $name);
// $console->addArgument('email', $email);
$name = 'Jill';
$email = 'jill@example.com';

$command = new CreateUser($repository = m::mock(UserRepositoryInterface::class));
$command->setLaravel($this->app);

$this->runCommand($command, ['name' => $name, 'email' => $email]);
}

$console->handle($this->dispatcher, $this->validation, $this->generator);
protected function runCommand($command, $input = [])
{
return $command->run(new ArrayInput($input), new NullOutput());
}
}

0 comments on commit ea87dc7

Please sign in to comment.