|
|
@@ -111,7 +111,7 @@ class ConnectionTest extends TestCase {
|
|
|
*
|
|
|
* @expectedException \Cake\Database\Error\MissingConnectionException
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testWrongCredentials() {
|
|
|
$config = ConnectionManager::config('test');
|
|
|
$this->skipIf(isset($config['dsn']), 'Datasource has dsn, skipping.');
|
|
|
@@ -123,7 +123,7 @@ class ConnectionTest extends TestCase {
|
|
|
* Tests creation of prepared statements
|
|
|
*
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testPrepare() {
|
|
|
$sql = 'SELECT 1 + 1';
|
|
|
$result = $this->connection->prepare($sql);
|
|
|
@@ -141,7 +141,7 @@ class ConnectionTest extends TestCase {
|
|
|
* Tests executing a simple query using bound values
|
|
|
*
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testExecuteWithArguments() {
|
|
|
$sql = 'SELECT 1 + ?';
|
|
|
$statement = $this->connection->execute($sql, [1], array('integer'));
|
|
|
@@ -169,7 +169,7 @@ class ConnectionTest extends TestCase {
|
|
|
* Tests executing a query with params and associated types
|
|
|
*
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testExecuteWithArgumentsAndTypes() {
|
|
|
$sql = "SELECT '2012-01-01' = ?";
|
|
|
$statement = $this->connection->execute($sql, [new \DateTime('2012-01-01')], ['date']);
|
|
|
@@ -183,7 +183,7 @@ class ConnectionTest extends TestCase {
|
|
|
*
|
|
|
* @expectedException \InvalidArgumentException
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testExecuteWithMissingType() {
|
|
|
$sql = 'SELECT ?';
|
|
|
$statement = $this->connection->execute($sql, [new \DateTime('2012-01-01')], ['bar']);
|
|
|
@@ -193,7 +193,7 @@ class ConnectionTest extends TestCase {
|
|
|
* Tests executing a query with no params also works
|
|
|
*
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testExecuteWithNoParams() {
|
|
|
$sql = 'SELECT 1';
|
|
|
$statement = $this->connection->execute($sql);
|
|
|
@@ -207,7 +207,7 @@ class ConnectionTest extends TestCase {
|
|
|
* Tests it is possible to insert data into a table using matching types by key name
|
|
|
*
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testInsertWithMatchingTypes() {
|
|
|
$data = ['id' => '3', 'title' => 'a title', 'body' => 'a body'];
|
|
|
$result = $this->connection->insert(
|
|
|
@@ -228,7 +228,7 @@ class ConnectionTest extends TestCase {
|
|
|
* Tests it is possible to insert data into a table using matching types by array position
|
|
|
*
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testInsertWithPositionalTypes() {
|
|
|
$data = ['id' => '3', 'title' => 'a title', 'body' => 'a body'];
|
|
|
$result = $this->connection->insert(
|
|
|
@@ -249,7 +249,7 @@ class ConnectionTest extends TestCase {
|
|
|
* Tests an statement class can be reused for multiple executions
|
|
|
*
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testStatementReusing() {
|
|
|
$total = $this->connection->execute('SELECT COUNT(*) AS total FROM things');
|
|
|
$result = $total->fetch('assoc');
|
|
|
@@ -271,7 +271,7 @@ class ConnectionTest extends TestCase {
|
|
|
* Tests rows can be updated without specifying any conditions nor types
|
|
|
*
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testUpdateWithoutConditionsNorTypes() {
|
|
|
$title = 'changed the title!';
|
|
|
$body = 'changed the body!';
|
|
|
@@ -285,7 +285,7 @@ class ConnectionTest extends TestCase {
|
|
|
* Tests it is possible to use key => value conditions for update
|
|
|
*
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testUpdateWithConditionsNoTypes() {
|
|
|
$title = 'changed the title!';
|
|
|
$body = 'changed the body!';
|
|
|
@@ -299,7 +299,7 @@ class ConnectionTest extends TestCase {
|
|
|
* Tests it is possible to use key => value and string conditions for update
|
|
|
*
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testUpdateWithConditionsCombinedNoTypes() {
|
|
|
$title = 'changed the title!';
|
|
|
$body = 'changed the body!';
|
|
|
@@ -313,7 +313,7 @@ class ConnectionTest extends TestCase {
|
|
|
* Tests you can bind types to update values
|
|
|
*
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testUpdateWithTypes() {
|
|
|
$title = 'changed the title!';
|
|
|
$body = new \DateTime('2012-01-01');
|
|
|
@@ -332,7 +332,7 @@ class ConnectionTest extends TestCase {
|
|
|
* Tests you can bind types to update values
|
|
|
*
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testUpdateWithConditionsAndTypes() {
|
|
|
$title = 'changed the title!';
|
|
|
$body = new \DateTime('2012-01-01');
|
|
|
@@ -349,7 +349,7 @@ class ConnectionTest extends TestCase {
|
|
|
* Tests delete from table with no conditions
|
|
|
*
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testDeleteNoConditions() {
|
|
|
$this->connection->delete('things');
|
|
|
$result = $this->connection->execute('SELECT * FROM things');
|
|
|
@@ -360,7 +360,7 @@ class ConnectionTest extends TestCase {
|
|
|
/**
|
|
|
* Tests delete from table with conditions
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testDeleteWithConditions() {
|
|
|
$this->connection->delete('things', ['id' => '1-rest-is-ommited'], ['id' => 'integer']);
|
|
|
$result = $this->connection->execute('SELECT * FROM things');
|
|
|
@@ -382,7 +382,7 @@ class ConnectionTest extends TestCase {
|
|
|
* Tests that it is possible to use simple database transactions
|
|
|
*
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testSimpleTransactions() {
|
|
|
$this->connection->begin();
|
|
|
$this->connection->delete('things', ['id' => 1]);
|
|
|
@@ -403,7 +403,7 @@ class ConnectionTest extends TestCase {
|
|
|
* with early rollback algorithm
|
|
|
*
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testVirtualNestedTrasanction() {
|
|
|
//starting 3 virtual transaction
|
|
|
$this->connection->begin();
|
|
|
@@ -426,7 +426,7 @@ class ConnectionTest extends TestCase {
|
|
|
* with early rollback algorithm
|
|
|
*
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testVirtualNestedTrasanction2() {
|
|
|
//starting 3 virtual transaction
|
|
|
$this->connection->begin();
|
|
|
@@ -447,7 +447,7 @@ class ConnectionTest extends TestCase {
|
|
|
* with early rollback algorithm
|
|
|
*
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
|
|
|
public function testVirtualNestedTrasanction3() {
|
|
|
//starting 3 virtual transaction
|
|
|
@@ -470,7 +470,7 @@ class ConnectionTest extends TestCase {
|
|
|
* Tests that it is possible to real use nested transactions
|
|
|
*
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testSavePoints() {
|
|
|
$this->skipIf(!$this->connection->useSavePoints(true));
|
|
|
|
|
|
@@ -498,7 +498,7 @@ class ConnectionTest extends TestCase {
|
|
|
* Tests that it is possible to real use nested transactions
|
|
|
*
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
|
|
|
public function testSavePoints2() {
|
|
|
$this->skipIf(!$this->connection->useSavePoints(true));
|
|
|
@@ -526,7 +526,7 @@ class ConnectionTest extends TestCase {
|
|
|
* Tests connection can quote values to be safely used in query strings
|
|
|
*
|
|
|
* @return void
|
|
|
- **/
|
|
|
+ */
|
|
|
public function testQuote() {
|
|
|
$this->skipIf(!$this->connection->supportsQuoting());
|
|
|
$expected = "'2012-01-01'";
|