Skip to content

Commit

Permalink
declarations of setUp and tearDown updated for v1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
gecche committed Oct 29, 2019
1 parent 5f6e1bd commit 1f2e8e0
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 114 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
}
],
"require": {
"laravel/framework": "~5.7.0"
"laravel/framework": "~5.8.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^7.0",
"limedeck/phpunit-detailed-printer": "^4.2",
"orchestra/testbench": "~3.7.0",
"orchestra/testbench-browser-kit": "~3.7.0"
"orchestra/testbench": "~3.8.0",
"orchestra/testbench-browser-kit": "~3.8.0"
},
"autoload": {
"classmap": [
Expand Down
216 changes: 108 additions & 108 deletions tests/src/ArtisanTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ArtisanTestCase extends TestCase
*
* @return void
*/
public function setUp()
protected function setUp(): void
{
$this->files = new Filesystem();
$this->laravelAppPath = __DIR__ . '/../../vendor/orchestra/testbench-core/laravel';
Expand All @@ -75,7 +75,7 @@ public function setUp()
}


protected function tearDown() {
protected function tearDown(): void {

$this->files->delete($this->laravelAppPath.'/.env');
copy($this->laravelAppPath.'/config/appORIG.php',$this->laravelAppPath.'/config/app.php');
Expand Down Expand Up @@ -106,39 +106,39 @@ protected function getEnvironmentSetUp($app)
* Then we launch the "name" command twice: without options and with the --domain=site1.test option.
* We expect to see "Laravel" andd then "LARAVELTEST" accordingly.
*/
// public function testBasicCommand() {
//
// //Note that if the $_SERVER['SERVER_NAME'] value has been set and the --domain option has NOT been set,
// //the $_SERVER['SERVER_NAME'] value acts as the --domain option value.
// $serverName = Arr::get($_SERVER,'SERVER_NAME');
//
// $process = new Process('php '.$this->laravelAppPath.'/artisan domain:add site1.test');
// $process->run();
//
// $process = new Process('php '.$this->laravelAppPath.'/artisan domain:update_env site1.test --domain_values=\'{"APP_NAME":"LARAVELTEST"}\'');
// $process->run();
//
// $process = new Process('php '.$this->laravelAppPath.'/artisan name');
// $process->run();
//
// if ($serverName == 'site1.test') {
// $this->assertEquals("LARAVELTEST",$process->getOutput());
// } else {
// $this->assertEquals("Laravel",$process->getOutput());
// }
//
// $process = new Process('php '.$this->laravelAppPath.'/artisan name --domain=site1.test');
// $process->run();
// $this->assertEquals("LARAVELTEST",$process->getOutput());
//
// $process = new Process('php '.$this->laravelAppPath.'/artisan domain:remove site1.test --force');
// $process->run();
//
//
// return;
//
// }
//
public function testBasicCommand() {

//Note that if the $_SERVER['SERVER_NAME'] value has been set and the --domain option has NOT been set,
//the $_SERVER['SERVER_NAME'] value acts as the --domain option value.
$serverName = Arr::get($_SERVER,'SERVER_NAME');

$process = new Process('php '.$this->laravelAppPath.'/artisan domain:add site1.test');
$process->run();

$process = new Process('php '.$this->laravelAppPath.'/artisan domain:update_env site1.test --domain_values=\'{"APP_NAME":"LARAVELTEST"}\'');
$process->run();

$process = new Process('php '.$this->laravelAppPath.'/artisan name');
$process->run();

if ($serverName == 'site1.test') {
$this->assertEquals("LARAVELTEST",$process->getOutput());
} else {
$this->assertEquals("Laravel",$process->getOutput());
}

$process = new Process('php '.$this->laravelAppPath.'/artisan name --domain=site1.test');
$process->run();
$this->assertEquals("LARAVELTEST",$process->getOutput());

$process = new Process('php '.$this->laravelAppPath.'/artisan domain:remove site1.test --force');
$process->run();


return;

}

/*
* TEST FOR QUEUE COMMANDS
* In this test we check that queues with the database driver refer to the correct db depending upon the domain.
Expand All @@ -152,79 +152,79 @@ protected function getEnvironmentSetUp($app)
* Last, we repeat the check with the other db.
*
*/
// public function testQueueCommand() {
// //Note that if the $_SERVER['SERVER_NAME'] value has been set and the --domain option has NOT been set,
// //the $_SERVER['SERVER_NAME'] value acts as the --domain option value.
// // So all the artisan commands run as if the option were instantiated.
// $serverName = Arr::get($_SERVER,'SERVER_NAME');
//
//
// //ADDING DOMAIN AND UPDATING ENV
// $process = new Process('php '.$this->laravelAppPath.'/artisan domain:add site1.test');
// $process->run();
//
// $process = new Process('php '.$this->laravelAppPath.'/artisan domain:update_env site1.test --domain_values=\'{"DB_DATABASE":"site1"}\'');
// $process->run();
//
//
// //RESET MIGRATIONS IN BOTH DBS
// $process = new Process('php '.$this->laravelAppPath.'/artisan migrate:reset');
// $process->run();
// $process = new Process('php '.$this->laravelAppPath.'/artisan migrate:reset --domain=site1.test');
// $process->run();
//
// //MIGRATIONS WITHOUT DOMAIN OPTION
// $process = new Process('php '.$this->laravelAppPath.'/artisan migrate');
// $process->run();
//// $this->assertEquals("Laravel",$process->getOutput());
//
//
// //CHECK QUEUE:FLUSH COMMAND: SUCCESS WITHOUT OPTIONS AND FAILURE WITH DOMAIN OPTION
// $process = new Process('php '.$this->laravelAppPath.'/artisan queue:flush');
// $process->run();
// $this->assertContains('All failed jobs deleted successfully!',$process->getOutput());
//
// $process = new Process('php '.$this->laravelAppPath.'/artisan queue:flush --domain=site1.test');
// $process->run();
// if ($serverName == 'site1.test') {
// $this->assertContains('All failed jobs deleted successfully!',$process->getOutput());
// } else {
// $this->assertContains('SQLSTATE[42S02]: Base table or view not found: 1146 Table \'site1.failed',$process->getOutput());
// }
//
//
//
// //RESET MIGRATIONS IN BOTH DBS
// $process = new Process('php '.$this->laravelAppPath.'/artisan migrate:reset');
// $process->run();
// $process = new Process('php '.$this->laravelAppPath.'/artisan migrate:reset --domain=site1.test');
// $process->run();
//
// //MIGRATIONS WITH DOMAIN OPTION
// $process = new Process('php '.$this->laravelAppPath.'/artisan migrate --domain=site1.test');
// $process->run();
//// $this->assertEquals("Laravel",$process->getOutput());
//
// //CHECK QUEUE:FLUSH COMMAND: SUCCESS WITH DOMAIN OPTIION AND FAILURE WITHOUT
// $process = new Process('php '.$this->laravelAppPath.'/artisan queue:flush --domain=site1.test');
// $process->run();
// $this->assertContains('All failed jobs deleted successfully!',$process->getOutput());
//
// $process = new Process('php '.$this->laravelAppPath.'/artisan queue:flush');
// $process->run();
// if ($serverName == 'site1.test') {
// $this->assertContains('All failed jobs deleted successfully!',$process->getOutput());
// } else {
// $this->assertContains('SQLSTATE[42S02]: Base table or view not found: 1146 Table \'homestead.failed',$process->getOutput());
// }
//
// $process = new Process('php '.$this->laravelAppPath.'/artisan domain:remove site1.test --force');
// $process->run();
//
// return;
//
// }
//
public function testQueueCommand() {
//Note that if the $_SERVER['SERVER_NAME'] value has been set and the --domain option has NOT been set,
//the $_SERVER['SERVER_NAME'] value acts as the --domain option value.
// So all the artisan commands run as if the option were instantiated.
$serverName = Arr::get($_SERVER,'SERVER_NAME');


//ADDING DOMAIN AND UPDATING ENV
$process = new Process('php '.$this->laravelAppPath.'/artisan domain:add site1.test');
$process->run();

$process = new Process('php '.$this->laravelAppPath.'/artisan domain:update_env site1.test --domain_values=\'{"DB_DATABASE":"site1"}\'');
$process->run();


//RESET MIGRATIONS IN BOTH DBS
$process = new Process('php '.$this->laravelAppPath.'/artisan migrate:reset');
$process->run();
$process = new Process('php '.$this->laravelAppPath.'/artisan migrate:reset --domain=site1.test');
$process->run();

//MIGRATIONS WITHOUT DOMAIN OPTION
$process = new Process('php '.$this->laravelAppPath.'/artisan migrate');
$process->run();
// $this->assertEquals("Laravel",$process->getOutput());


//CHECK QUEUE:FLUSH COMMAND: SUCCESS WITHOUT OPTIONS AND FAILURE WITH DOMAIN OPTION
$process = new Process('php '.$this->laravelAppPath.'/artisan queue:flush');
$process->run();
$this->assertContains('All failed jobs deleted successfully!',$process->getOutput());

$process = new Process('php '.$this->laravelAppPath.'/artisan queue:flush --domain=site1.test');
$process->run();
if ($serverName == 'site1.test') {
$this->assertContains('All failed jobs deleted successfully!',$process->getOutput());
} else {
$this->assertContains('SQLSTATE[42S02]: Base table or view not found: 1146 Table \'site1.failed',$process->getOutput());
}



//RESET MIGRATIONS IN BOTH DBS
$process = new Process('php '.$this->laravelAppPath.'/artisan migrate:reset');
$process->run();
$process = new Process('php '.$this->laravelAppPath.'/artisan migrate:reset --domain=site1.test');
$process->run();

//MIGRATIONS WITH DOMAIN OPTION
$process = new Process('php '.$this->laravelAppPath.'/artisan migrate --domain=site1.test');
$process->run();
// $this->assertEquals("Laravel",$process->getOutput());

//CHECK QUEUE:FLUSH COMMAND: SUCCESS WITH DOMAIN OPTIION AND FAILURE WITHOUT
$process = new Process('php '.$this->laravelAppPath.'/artisan queue:flush --domain=site1.test');
$process->run();
$this->assertContains('All failed jobs deleted successfully!',$process->getOutput());

$process = new Process('php '.$this->laravelAppPath.'/artisan queue:flush');
$process->run();
if ($serverName == 'site1.test') {
$this->assertContains('All failed jobs deleted successfully!',$process->getOutput());
} else {
$this->assertContains('SQLSTATE[42S02]: Base table or view not found: 1146 Table \'homestead.failed',$process->getOutput());
}

$process = new Process('php '.$this->laravelAppPath.'/artisan domain:remove site1.test --force');
$process->run();

return;

}

/*
* TEST FOR QUEUE LISTEN COMMAND
* In this test we check that queues listeners applied to distinct domains work with the jobs pushed from
Expand Down
2 changes: 1 addition & 1 deletion tests/src/CommandsTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CommandsTestCase extends \Orchestra\Testbench\TestCase
*
* @return void
*/
public function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
4 changes: 2 additions & 2 deletions tests/src/HttpTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class HttpTestCase extends \Orchestra\Testbench\BrowserKit\TestCase
*
* @return void
*/
public function setUp()
protected function setUp(): void
{
$process = new Process('php '.$this->laravelAppPath.'/artisan config:clear');
$process->run();
Expand Down Expand Up @@ -102,7 +102,7 @@ public function setUp()

}

protected function tearDown()
protected function tearDown(): void
{
$this->artisan('domain:remove', ['domain' => $this->site1, '--force' => 1]);
$this->artisan('domain:remove', ['domain' => $this->site2, '--force' => 1]);
Expand Down

0 comments on commit 1f2e8e0

Please sign in to comment.