This repository has been archived by the owner on Aug 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now you can setup new option to 'shareDatabase:yes' and in this case new database will be created but will NOT be deleted after test case. This means that database is shared with one thread. There will be up to 8 databases in case you are using 8 threads. Default behavior is "always create and delete database" therefore it's without BC break: testbench: shareDatabase: no Related PR: #38 Close issue #37
- Loading branch information
Showing
8 changed files
with
130 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Testbench; | ||
|
||
class DatabasesRegistry | ||
{ | ||
|
||
private $dataFile; | ||
|
||
public function __construct() | ||
{ | ||
$this->dataFile = 'nette.safe://' . \Testbench\Bootstrap::$tempDir . '/../databases.testbench'; | ||
} | ||
|
||
/** | ||
* @return TRUE if registration successful or FALSE if database record already exists | ||
*/ | ||
public function registerDatabase($databaseName) | ||
{ | ||
if (file_exists($this->dataFile)) { | ||
$data = file_get_contents($this->dataFile); | ||
} else { | ||
$data = ''; | ||
} | ||
|
||
if (!preg_match('~' . $databaseName . '~', $data)) { //database doesn't exist in log file | ||
$handle = fopen($this->dataFile, 'a+'); | ||
fwrite($handle, $databaseName . "\n"); | ||
fclose($handle); | ||
|
||
return TRUE; | ||
} else { //database already exists in log file | ||
return FALSE; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
tests.local.neon | ||
_temp/ | ||
**/output/ | ||
tests.log | ||
databases.testbench |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters