Skip to content

Commit

Permalink
[homekit-connector][shelly-connector] Refactoring to configuration (#…
Browse files Browse the repository at this point in the history
…172)
  • Loading branch information
actions-user committed Nov 19, 2023
1 parent 9719c16 commit e38dd79
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
6 changes: 5 additions & 1 deletion tests/cases/unit/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
use function constant;
use function defined;
use function file_exists;
use function getmypid;
use function md5;
use function strval;
use function time;

abstract class BaseTestCase extends TestCase
Expand Down Expand Up @@ -43,7 +45,9 @@ protected function createContainer(string|null $additionalConfig = null): Nette\
$config->setForceReloadContainer();
$config->setTempDirectory(FB_TEMP_DIR);

$config->addStaticParameters(['container' => ['class' => 'SystemContainer_' . md5((string) time())]]);
$config->addStaticParameters(
['container' => ['class' => 'SystemContainer_' . strval(getmypid()) . md5((string) time())]],
);
$config->addStaticParameters(['appDir' => $rootDir, 'wwwDir' => $rootDir, 'vendorDir' => $vendorDir]);

$config->addConfig(__DIR__ . '/../../common.neon');
Expand Down
6 changes: 5 additions & 1 deletion tests/cases/unit/DbTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
use function feof;
use function fgets;
use function fopen;
use function getmypid;
use function in_array;
use function md5;
use function rtrim;
use function set_time_limit;
use function sprintf;
use function strlen;
use function strval;
use function substr;
use function time;
use function trim;
Expand Down Expand Up @@ -130,7 +132,9 @@ private function createContainer(): Nette\DI\Container
$config->setForceReloadContainer();
$config->setTempDirectory(FB_TEMP_DIR);

$config->addStaticParameters(['container' => ['class' => 'SystemContainer_' . md5((string) time())]]);
$config->addStaticParameters(
['container' => ['class' => 'SystemContainer_' . strval(getmypid()) . md5((string) time())]],
);
$config->addStaticParameters(['appDir' => $rootDir, 'wwwDir' => $rootDir, 'vendorDir' => $vendorDir]);

$config->addConfig(__DIR__ . '/../../common.neon');
Expand Down
4 changes: 2 additions & 2 deletions tests/tools/ConnectionWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function __construct(
)
{
$this->dbName = is_string(getenv('TEST_TOKEN'))
? 'fb_test_' . getmypid() . getenv('TEST_TOKEN') ?? ''
: 'fb_test_' . getmypid();
? 'fb_test_' . getmypid() . md5((string) time()) . getenv('TEST_TOKEN') ?? ''
: 'fb_test_' . getmypid() . md5((string) time());

unset($params['dbname']);

Expand Down
16 changes: 9 additions & 7 deletions tools/phpunit-bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

// phpcs:ignoreFile

if (!defined('FB_TEMP_DIR')) {
define('FB_TEMP_DIR', __DIR__ . '/../var/tools/PHPUnit/tmp');
}

if (!defined('FB_LOGS_DIR')) {
define('FB_LOGS_DIR', __DIR__ . '/../var/tools/PHPUnit/logs');
}
define('FB_APP_DIR', realpath(__DIR__ . '/..'));
define('FB_CONFIG_DIR', realpath(__DIR__ . '/../config'));
define('FB_VENDOR_DIR', realpath(__DIR__ . '/../vendor'));
is_string(getenv('TEST_TOKEN'))
? define('FB_TEMP_DIR', __DIR__ . '/../var/tools/PHPUnit/tmp/' . getmypid() . '-' . md5((string) time()) . '-' . getenv('TEST_TOKEN') ?? '')
: define('FB_TEMP_DIR', __DIR__ . '/../var/tools/PHPUnit/tmp/' . getmypid() . '-' . md5((string) time()));
is_string(getenv('TEST_TOKEN'))
? define('FB_LOGS_DIR', __DIR__ . '/../var/tools/PHPUnit/logs/' . getmypid() . '-' . md5((string) time()) . '-' . getenv('TEST_TOKEN') ?? '')
: define('FB_LOGS_DIR', __DIR__ . '/../var/tools/PHPUnit/logs/' . getmypid() . '-' . md5((string) time()));

if (@!include __DIR__ . '/../vendor/autoload.php') {
echo 'Install Tester using `composer update --dev`';
Expand Down

0 comments on commit e38dd79

Please sign in to comment.