-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- トランザクション分離レベルを意識して、無駄な SQL 実行を避ける。#630 (comment) - 幾らかコストが低い exists() を使う。#630 (comment) - SC_DB_DBFactory のテストが無さそうなので、今回追加したメソッドの他、ごく基本的な部分のみ実装する。
- Loading branch information
1 parent
4d7ff5b
commit 3f08055
Showing
7 changed files
with
153 additions
and
4 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
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
class SC_DB_DBFactoryTest extends Common_TestCase | ||
{ | ||
/** | ||
* @var SC_DB_DBFactory_PGSQL | ||
*/ | ||
protected $dbFactoryPgsql; | ||
|
||
/** | ||
* @var SC_DB_DBFactory_MYSQL | ||
*/ | ||
protected $dbFactoryMysql; | ||
|
||
/** | ||
* @var SC_DB_DBFactory_MYSQL | ||
*/ | ||
protected $dbFactoryMysqli; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->dbFactoryPgsql = SC_DB_DBFactory_Ex::getInstance('pgsql'); | ||
$this->dbFactoryMysql = SC_DB_DBFactory_Ex::getInstance('mysql'); | ||
$this->dbFactoryMysqli = SC_DB_DBFactory_Ex::getInstance('mysqli'); | ||
} | ||
|
||
public function testGetInstance_pgsql() | ||
{ | ||
$this->assertInstanceOf('SC_DB_DBFactory', $this->dbFactoryPgsql); | ||
$this->assertInstanceOf('SC_DB_DBFactory_Ex', $this->dbFactoryPgsql); | ||
$this->assertInstanceOf('SC_DB_DBFactory_PGSQL', $this->dbFactoryPgsql); | ||
$this->assertInstanceOf('SC_DB_DBFactory_PGSQL_Ex', $this->dbFactoryPgsql); | ||
} | ||
|
||
public function testGetInstance_mysql() | ||
{ | ||
$this->assertInstanceOf('SC_DB_DBFactory', $this->dbFactoryMysql); | ||
$this->assertInstanceOf('SC_DB_DBFactory_Ex', $this->dbFactoryMysql); | ||
$this->assertInstanceOf('SC_DB_DBFactory_MYSQL', $this->dbFactoryMysql); | ||
$this->assertInstanceOf('SC_DB_DBFactory_MYSQL_Ex', $this->dbFactoryMysql); | ||
} | ||
|
||
public function testGetInstance_mysqli() | ||
{ | ||
$this->assertSame(get_class($this->dbFactoryMysql), get_class($this->dbFactoryMysqli)); | ||
} | ||
} |
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,30 @@ | ||
<?php | ||
|
||
class SC_DB_DBFactory_MYSQLTest extends Common_TestCase | ||
{ | ||
/** | ||
* @var SC_DB_DBFactory_MYSQL | ||
*/ | ||
protected $dbFactory; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->dbFactory = new SC_DB_DBFactory_MYSQL_Ex; | ||
} | ||
|
||
public function testGetInstance() | ||
{ | ||
$this->assertInstanceOf('SC_DB_DBFactory_MYSQL_Ex', $this->dbFactory); | ||
} | ||
|
||
public function testGetTransactionIsolationLevel() | ||
{ | ||
$this->assertEquals(SC_DB_DBFactory_Ex::ISOLATION_LEVEL_REPEATABLE_READ, $this->dbFactory->getTransactionIsolationLevel()); | ||
} | ||
|
||
public function testIsSkipDeleteIfNotExists() | ||
{ | ||
$this->assertEquals(true, $this->dbFactory->isSkipDeleteIfNotExists()); | ||
} | ||
} |
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,30 @@ | ||
<?php | ||
|
||
class SC_DB_DBFactory_PGSQLTest extends Common_TestCase | ||
{ | ||
/** | ||
* @var SC_DB_DBFactory_PGSQL | ||
*/ | ||
protected $dbFactory; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->dbFactory = new SC_DB_DBFactory_PGSQL_Ex; | ||
} | ||
|
||
public function testGetInstance() | ||
{ | ||
$this->assertInstanceOf('SC_DB_DBFactory_PGSQL_Ex', $this->dbFactory); | ||
} | ||
|
||
public function testGetTransactionIsolationLevel() | ||
{ | ||
$this->assertEquals(SC_DB_DBFactory_Ex::ISOLATION_LEVEL_READ_COMMITTED, $this->dbFactory->getTransactionIsolationLevel()); | ||
} | ||
|
||
public function testIsSkipDeleteIfNotExists() | ||
{ | ||
$this->assertEquals(false, $this->dbFactory->isSkipDeleteIfNotExists()); | ||
} | ||
} |