Skip to content

Commit

Permalink
chore: upgrade tests to 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
sqrtqiezi committed Mar 6, 2017
1 parent 5e29a06 commit 2faceb4
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 93 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "^5.4",
"laravel/laravel": "5.3.*"
"phpunit/phpunit": "~5.7",
"laravel/laravel": "5.4.*"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
Expand Down
177 changes: 87 additions & 90 deletions tests/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,109 +2,106 @@

namespace Summerblue\Generator\Tests;

use PHPUnit_Framework_TestCase as PHPUnit;
use PHPUnit\Framework\TestCase as PHPUnit;

use \Illuminate\Support\Facades\Artisan;
use \Illuminate\Filesystem\Filesystem;
use \Illuminate\Support\Composer;
use Mockery;


class CommandTest extends PHPUnit
{
protected $app;
protected $filesystem;
protected $folders;
protected $files;
protected $app;
protected $filesystem;
protected $folders;
protected $files;

public function setUp()
{
parent::setUp();

$this->prepareFilesystem();
public function setUp()
{
parent::setUp();

$this->createApplication();
$this->prepareFilesystem();

$this->mountFolderStructure();
}
$this->createApplication();

public function tearDown()
{
$this->cleanFilesystem();
}
$this->mountFolderStructure();
}

public function createApplication()
{
$this->app = require __DIR__.'/../vendor/laravel/laravel/bootstrap/app.php';

$this->app->register('Summerblue\Generator\GeneratorsServiceProvider');
public function tearDown()
{
$this->cleanFilesystem();
}

public function createApplication()
{
$this->app = require __DIR__ . '/../vendor/laravel/laravel/bootstrap/app.php';

$this->app->register('Summerblue\Generator\GeneratorsServiceProvider');

$this->app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();
}

public function prepareFilesystem()
{
$this->filesystem = new Filesystem();

$this->folders =
[
'routes',
'app/Http/Controllers',
'app/Models',
'app/Providers',
'database/seeds',
'database/migrations',
'database/factories',
'resources/views',
];

$this->files =
[
'./database/factories/ModelFactory.php',
'./database/seeds/DatabaseSeeder.php',
'./app/Models/Model.php',
'./app/Providers/AuthServiceProvider.php',
'./routes/web.php',
];

}

public function mountFolderStructure()
{
foreach($this->folders as $folder)
{
$this->filesystem->makeDirectory($folder, 0777, true, true);
}


foreach($this->files as $file)
{
$this->filesystem->put($file, '<?php');
}
}

public function cleanFilesystem()
{
foreach ($this->folders as $folder)
{
$this->filesystem->deleteDirectory(explode("/", $folder)[0]);
}
}

public function testExecuteCommand()
{
Artisan::call('make:scaffold',
[
'name' => 'Tweet',
'--schema' => 'title:string',
'--no-interaction'
]);

Artisan::call('make:scaffold',
[
'name' => 'Tweet2',
'--schema' => 'title:string',
'--no-interaction'
]);
}
}

public function prepareFilesystem()
{
$this->filesystem = new Filesystem();

$this->folders =
[
'routes',
'app/Http/Controllers',
'app/Models',
'app/Providers',
'database/seeds',
'database/migrations',
'database/factories',
'resources/views',
];

$this->files =
[
'./database/factories/ModelFactory.php',
'./database/seeds/DatabaseSeeder.php',
'./app/Models/Model.php',
'./app/Providers/AuthServiceProvider.php',
'./app/Providers/AppServiceProvider.php',
'./routes/web.php',
];

}

public function mountFolderStructure()
{
foreach ($this->folders as $folder) {
$this->filesystem->makeDirectory($folder, 0777, true, true);
}


foreach ($this->files as $file) {
$this->filesystem->put($file, '<?php');
}
}

public function cleanFilesystem()
{
foreach ($this->folders as $folder) {
$this->filesystem->deleteDirectory(explode("/", $folder)[0]);
}
}

public function testExecuteCommand()
{
Artisan::call('make:scaffold',
[
'name' => 'Tweet',
'--schema' => 'title:string',
'--no-interaction'
]);

Artisan::call('make:scaffold',
[
'name' => 'Tweet2',
'--schema' => 'title:string',
'--no-interaction'
]);
}
}
2 changes: 1 addition & 1 deletion tests/StartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Summerblue\Generator\Tests;

use PHPUnit_Framework_TestCase as PHPUnit;
use PHPUnit\Framework\TestCase as PHPUnit;

class StartTest extends PHPUnit
{
Expand Down

0 comments on commit 2faceb4

Please sign in to comment.