Skip to content

Commit

Permalink
Rename testing.php by tests.php
Browse files Browse the repository at this point in the history
Improve code readability
  • Loading branch information
eliseekn committed Feb 23, 2023
1 parent b4ab072 commit d22425f
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 16 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion core/Console/Database/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

if (is_null($databases) || empty($databases)) {
$db = config('app.env') !== 'test' ? config('database.name') :
config('database.name') . config('testing.database.suffix') ;
config('database.name') . config('tests.database.suffix') ;

$databases = [$db];
}
Expand Down
2 changes: 1 addition & 1 deletion core/Console/Database/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

if (is_null($databases) || empty($databases)) {
$db = config('app.env') !== 'test' ? config('database.name') :
config('database.name') . config('testing.database.suffix') ;
config('database.name') . config('tests.database.suffix') ;

$databases = [$db];
}
Expand Down
2 changes: 1 addition & 1 deletion core/Console/Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->getApplication()->find('migrations:reset')->run(new ArrayInput([]), $output);
$this->getApplication()->find('db:seed')->run(new ArrayInput([]), $output);

$server = new Process(['php', '-S', config('testing.host') . ':' . config('testing.port')]);
$server = new Process(['php', '-S', config('tests.host') . ':' . config('tests.port')]);
$server->setTimeout(null);
$server->start();

Expand Down
2 changes: 1 addition & 1 deletion core/Database/Connection/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Connection

private function __construct()
{
$driver = config('app.env') === 'test' ? config('testing.database.driver') : config('database.driver');
$driver = config('app.env') === 'test' ? config('tests.database.driver') : config('database.driver');

$this->db = $driver === 'mysql' ? new MySQLConnection() : new SQLiteConnection();
}
Expand Down
2 changes: 1 addition & 1 deletion core/Database/Connection/MySQLConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function deleteSchema(string $name)
private function getDB()
{
return config('app.env') === 'test'
? config('testing.database.suffix')
? config('tests.database.suffix')
: config('database.name') . '.db';
}
}
2 changes: 1 addition & 1 deletion core/Database/Connection/SQLiteConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct()
private function getDB()
{
if (config('app.env') === 'test') {
return config('storage.sqlite') . config('database.name') . config('testing.database.suffix') . '.db';
return config('storage.sqlite') . config('database.name') . config('tests.database.suffix') . '.db';
}

return config('database.sqlite.memory') ? ':memory:'
Expand Down
6 changes: 3 additions & 3 deletions core/Database/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ public static function dropForeign(string $table, string $name)

public static function disableForeignKeyCheck()
{
$driver = config('app.env') === 'test' ? $driver = config('testing.database.driver') : config('database.driver');
$driver = config('app.env') === 'test' ? $driver = config('tests.database.driver') : config('database.driver');
$query = $driver === 'mysql' ? 'SET foreign_key_checks = 0' : 'PRAGMA foreign_keys = OFF';

QueryBuilder::setQuery($query)->execute();
}

public static function enableForeignKeyCheck()
{
$driver = config('app.env') === 'test' ? $driver = config('testing.database.driver') : config('database.driver');
$driver = config('app.env') === 'test' ? $driver = config('tests.database.driver') : config('database.driver');
$query = $driver === 'mysql' ? 'SET foreign_key_checks = 1' : 'PRAGMA foreign_keys = ON';

QueryBuilder::setQuery($query)->execute();
Expand Down Expand Up @@ -297,7 +297,7 @@ public function primaryKey(): self

public function addPrimaryKey(string $column, bool $auto_increment = true): self
{
$driver = config('app.env') === 'test' ? $driver = config('testing.database.driver') : config('database.driver');
$driver = config('app.env') === 'test' ? $driver = config('tests.database.driver') : config('database.driver');

$pk = $driver === 'mysql' ? $this->addBigInt($column) : $this->addInteger($column);
$pk->primaryKey();
Expand Down
10 changes: 5 additions & 5 deletions core/Database/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ class QueryBuilder
protected static function setTable(string $name)
{
if (config('app.env') === 'test') {
if (config('testing.database.driver') === 'sqlite') {
if (config('tests.database.driver') === 'sqlite') {
return config('database.table_prefix') . $name;
}

return config('database.name') .config('testing.database.suffix') . '.' . config('database.table_prefix') . $name;
return config('database.name') .config('tests.database.suffix') . '.' . config('database.table_prefix') . $name;
}

if (config('database.driver') === 'sqlite') {
Expand Down Expand Up @@ -200,7 +200,7 @@ public function column(string $name, string $type): self

public function autoIncrement(): self
{
$driver = config('app.env') === 'test' ? $driver = config('testing.database.driver') : config('database.driver');
$driver = config('app.env') === 'test' ? $driver = config('tests.database.driver') : config('database.driver');

self::$query = rtrim(self::$query, ', ');
self::$query .= $driver === 'mysql' ? ' AUTO_INCREMENT, ' : ' AUTOINCREMENT, ';
Expand Down Expand Up @@ -274,7 +274,7 @@ public function onDeleteSetNull(): self

public function addCurrentTimestamp(string $created_at = 'created_at', string $updated_at = 'updated_at')
{
$driver = config('app.env') === 'test' ? $driver = config('testing.database.driver') : config('database.driver');
$driver = config('app.env') === 'test' ? $driver = config('tests.database.driver') : config('database.driver');

if ($driver === 'mysql') {
self::$query .= " {$created_at} TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, {$updated_at} TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ";
Expand All @@ -287,7 +287,7 @@ public function addCurrentTimestamp(string $created_at = 'created_at', string $u

public function migrate()
{
$driver = config('app.env') === 'test' ? $driver = config('testing.database.driver') : config('database.driver');
$driver = config('app.env') === 'test' ? $driver = config('tests.database.driver') : config('database.driver');

self::$query = rtrim(self::$query, ', ') . ')';

Expand Down
2 changes: 1 addition & 1 deletion core/Support/Metrics.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Metrics

public function __construct(public string $table, private string $driver = '')
{
$this->driver = config('app.env') === 'test' ? $driver = config('testing.database.driver') : config('database.driver');
$this->driver = config('app.env') === 'test' ? $driver = config('tests.database.driver') : config('database.driver');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion core/Testing/ApplicationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function tearDown(): void

protected function url(string $uri)
{
return config('testing.host') . ':' . config('testing.port') . '/' . ltrim($uri, '/');
return config('tests.host') . ':' . config('tests.port') . '/' . ltrim($uri, '/');
}

protected function getBody()
Expand Down

0 comments on commit d22425f

Please sign in to comment.