Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
More testing:
Browse files Browse the repository at this point in the history
* added mariadb as host.
  • Loading branch information
herpaderpaldent committed Oct 9, 2018
1 parent e18c926 commit b655beb
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 8 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"require-dev": {
"orchestra/testbench": "3.5.*",
"orchestra/database" : "~3.5",
"phpunit/phpunit": "~6.0"
},
"license": "GPL-2.0-only",
Expand Down
34 changes: 27 additions & 7 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,39 @@

abstract class TestCase extends Orchestra
{
protected function getPackageProviders($app)
{
return [GroupsServiceProvider::class];
}

/**
* Setup the test environment.
*/
protected function setUp()
{
parent::setUp();

/*$this->loadMigrationsFrom([
'--database' => 'testbench',
'--realpath' => realpath(__DIR__ . '/database/migrations')
]);*/
$this->artisan('migrate', ['--database' => 'testbench']);
$this->withFactories(__DIR__ . '/database/factories');

// and other test setup steps you need to perform
}


/**
* Get application providers.
*
* @param \Illuminate\Foundation\Application $app
*
* @return array
*/
protected function getPackageProviders($app)
{
return [
\Orchestra\Database\ConsoleServiceProvider::class,
GroupsServiceProvider::class
];
}

/**
* Define environment setup.
*
Expand All @@ -39,11 +54,16 @@ protected function setUp()
*/
protected function getEnvironmentSetUp($app)
{
//TODO: find a better way or use dedicated DB
// Setup default database to use sqlite :memory:
$app['config']->set('database.default', 'testbench');
$app['config']->set('database.connections.testbench', [
'driver' => 'sqlite',
'database' => ':memory:',
'driver' => 'mysql',
'host' => env('DB_HOST', 'mariadb'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'seat-dev'),
'username' => env('DB_USERNAME', 'seat'),
'password' => env('DB_PASSWORD', 'seatseat'),
'prefix' => '',
]);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/database/factories/SeatgroupFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
'name' => $faker->name,
'description' => $faker->text,
'type' => $faker->randomElement(['auto', 'open', 'managed', 'hidden']),
'all_corporation' => $faker->boolean,
'all_corporations' => $faker->boolean,
];
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

/*
* This file is part of SeAT
*
* Copyright (C) 2015, 2016, 2017, 2018 Leon Jacobs
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateSchedulesTestTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{

if(!Schema::hasTable('schedules'))
{
Schema::create('schedules', function (Blueprint $table) {

$table->increments('id');
$table->string('command');
$table->string('expression');
$table->boolean('allow_overlap')->default(false);
$table->boolean('allow_maintenance')->default(false);
$table->string('ping_before')->nullable();
$table->string('ping_after')->nullable();

$table->timestamps();
});
}


}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{

Schema::dropIfExists('schedules');
}
}

0 comments on commit b655beb

Please sign in to comment.