mirror of
https://github.com/superhelio/commands.git
synced 2026-01-26 03:33:59 +00:00
Testing Orchestra/TestBench workflow
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
composer.lock
|
||||
vendor
|
||||
@@ -21,7 +21,8 @@
|
||||
"illuminate/support": "~5.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit" : "4.*"
|
||||
"phpunit/phpunit" : "4.*",
|
||||
"orchestra/testbench": "~3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
@@ -5,10 +5,63 @@ use Superhelio\Commands\Commands\Gozer;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class GozerTest extends \PHPUnit_Framework_TestCase
|
||||
class GozerTest extends \Orchestra\Testbench\TestCase
|
||||
{
|
||||
/**
|
||||
* Setup the test environment.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->artisan('migrate', ['--database' => 'testbench']);
|
||||
}
|
||||
/**
|
||||
* Define environment setup.
|
||||
*
|
||||
* @param \Illuminate\Foundation\Application $app
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getEnvironmentSetUp($app)
|
||||
{
|
||||
// Setup default database to use sqlite :memory:
|
||||
$app['config']->set('database.default', 'testbench');
|
||||
$app['config']->set('database.connections.testbench', [
|
||||
'driver' => 'sqlite',
|
||||
'database' => ':memory:',
|
||||
'prefix' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get package providers. At a minimum this is the package being tested, but also
|
||||
* would include packages upon which our package depends, e.g. Cartalyst/Sentry
|
||||
* In a normal app environment these would be added to the 'providers' array in
|
||||
* the config/app.php file.
|
||||
*
|
||||
* @param \Illuminate\Foundation\Application $app
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getPackageProviders($app)
|
||||
{
|
||||
return [
|
||||
\Superhelio\Commands\Tests\Stubs\ServiceProvider::class,
|
||||
\Superhelio\Commands\ServiceProvider::class
|
||||
];
|
||||
}
|
||||
|
||||
public function testGozerTest()
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
\DB::table('users')->insert([
|
||||
'name' => 'User name',
|
||||
'email' => 'hello@gozer.dev',
|
||||
'password' => bcrypt('123')
|
||||
]);
|
||||
|
||||
$users = \DB::table('users')->where('id', '=', 1)->first();
|
||||
$this->assertEquals('hello@gozer.dev', $users->email);
|
||||
$this->assertEquals('User name', $users->name);
|
||||
$this->assertTrue(\Hash::check('123', $users->password));
|
||||
}
|
||||
}
|
||||
|
||||
10
tests/Stubs/ServiceProvider.php
Normal file
10
tests/Stubs/ServiceProvider.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace Superhelio\Commands\Tests\Stubs;
|
||||
|
||||
class ServiceProvider extends \Illuminate\Support\ServiceProvider
|
||||
{
|
||||
public function boot()
|
||||
{
|
||||
$this->loadMigrationsFrom(realpath(__DIR__ . '/../migrations'));
|
||||
}
|
||||
}
|
||||
35
tests/migrations/2014_10_12_000000_create_users_table.php
Normal file
35
tests/migrations/2014_10_12_000000_create_users_table.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateUsersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user