@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('PHPUnit_MAIN_METHOD')) { |
|
3 | +if (!defined('PHPUnit_MAIN_METHOD')) { |
|
4 | 4 | define('PHPUnit_MAIN_METHOD', 'IO_AllTests::main'); |
5 | 5 | } |
6 | 6 | |
@@ -22,6 +22,6 @@ discard block |
||
22 | 22 | } |
23 | 23 | } |
24 | 24 | |
25 | -if(PHPUnit_MAIN_METHOD == 'IO_AllTests::main') { |
|
25 | +if (PHPUnit_MAIN_METHOD == 'IO_AllTests::main') { |
|
26 | 26 | IO_AllTests::main(); |
27 | 27 | } |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | Prado::using('System.Data.*'); |
4 | 4 | |
5 | -if(!defined('TEST_DB_FILE')) |
|
6 | - define('TEST_DB_FILE',dirname(__FILE__).'/db/test.db'); |
|
5 | +if (!defined('TEST_DB_FILE')) |
|
6 | + define('TEST_DB_FILE', dirname(__FILE__) . '/db/test.db'); |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * @package System.Data.PDO |
@@ -17,22 +17,22 @@ discard block |
||
17 | 17 | @unlink(TEST_DB_FILE); |
18 | 18 | |
19 | 19 | // create application just to provide application mode |
20 | - new TApplication(__DIR__, false ,TApplication::CONFIG_TYPE_PHP); |
|
20 | + new TApplication(__DIR__, false, TApplication::CONFIG_TYPE_PHP); |
|
21 | 21 | |
22 | - $this->_connection=new TDbConnection('sqlite:'.TEST_DB_FILE); |
|
23 | - $this->_connection->Active=true; |
|
22 | + $this->_connection = new TDbConnection('sqlite:' . TEST_DB_FILE); |
|
23 | + $this->_connection->Active = true; |
|
24 | 24 | $this->_connection->createCommand('CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name VARCHAR(8))')->execute(); |
25 | 25 | } |
26 | 26 | |
27 | 27 | public function tearDown() |
28 | 28 | { |
29 | - $this->_connection=null; |
|
29 | + $this->_connection = null; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function testRollBack() |
33 | 33 | { |
34 | - $sql='INSERT INTO foo(id,name) VALUES (1,\'my name\')'; |
|
35 | - $transaction=$this->_connection->beginTransaction(); |
|
34 | + $sql = 'INSERT INTO foo(id,name) VALUES (1,\'my name\')'; |
|
35 | + $transaction = $this->_connection->beginTransaction(); |
|
36 | 36 | try |
37 | 37 | { |
38 | 38 | $this->_connection->createCommand($sql)->execute(); |
@@ -40,21 +40,21 @@ discard block |
||
40 | 40 | $this->fail('Expected exception not raised'); |
41 | 41 | $transaction->commit(); |
42 | 42 | } |
43 | - catch(Exception $e) |
|
43 | + catch (Exception $e) |
|
44 | 44 | { |
45 | 45 | $this->assertTrue($transaction->Active); |
46 | 46 | $transaction->rollBack(); |
47 | 47 | $this->assertFalse($transaction->Active); |
48 | - $reader=$this->_connection->createCommand('SELECT * FROM foo')->query(); |
|
48 | + $reader = $this->_connection->createCommand('SELECT * FROM foo')->query(); |
|
49 | 49 | $this->assertFalse($reader->read()); |
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | 53 | public function testCommit() |
54 | 54 | { |
55 | - $sql1='INSERT INTO foo(id,name) VALUES (1,\'my name\')'; |
|
56 | - $sql2='INSERT INTO foo(id,name) VALUES (2,\'my name\')'; |
|
57 | - $transaction=$this->_connection->beginTransaction(); |
|
55 | + $sql1 = 'INSERT INTO foo(id,name) VALUES (1,\'my name\')'; |
|
56 | + $sql2 = 'INSERT INTO foo(id,name) VALUES (2,\'my name\')'; |
|
57 | + $transaction = $this->_connection->beginTransaction(); |
|
58 | 58 | try |
59 | 59 | { |
60 | 60 | $this->_connection->createCommand($sql1)->execute(); |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | $transaction->commit(); |
64 | 64 | $this->assertFalse($transaction->Active); |
65 | 65 | } |
66 | - catch(Exception $e) |
|
66 | + catch (Exception $e) |
|
67 | 67 | { |
68 | 68 | $transaction->rollBack(); |
69 | 69 | $this->fail('Unexpected exception'); |
70 | 70 | } |
71 | - $result=$this->_connection->createCommand('SELECT * FROM foo')->query()->readAll(); |
|
72 | - $this->assertEquals(count($result),2); |
|
71 | + $result = $this->_connection->createCommand('SELECT * FROM foo')->query()->readAll(); |
|
72 | + $this->assertEquals(count($result), 2); |
|
73 | 73 | } |
74 | 74 | } |
@@ -2,8 +2,9 @@ discard block |
||
2 | 2 | |
3 | 3 | Prado::using('System.Data.*'); |
4 | 4 | |
5 | -if(!defined('TEST_DB_FILE')) |
|
5 | +if(!defined('TEST_DB_FILE')) { |
|
6 | 6 | define('TEST_DB_FILE',dirname(__FILE__).'/db/test.db'); |
7 | +} |
|
7 | 8 | |
8 | 9 | /** |
9 | 10 | * @package System.Data.PDO |
@@ -39,8 +40,7 @@ discard block |
||
39 | 40 | $this->_connection->createCommand($sql)->execute(); |
40 | 41 | $this->fail('Expected exception not raised'); |
41 | 42 | $transaction->commit(); |
42 | - } |
|
43 | - catch(Exception $e) |
|
43 | + } catch(Exception $e) |
|
44 | 44 | { |
45 | 45 | $this->assertTrue($transaction->Active); |
46 | 46 | $transaction->rollBack(); |
@@ -62,8 +62,7 @@ discard block |
||
62 | 62 | $this->assertTrue($transaction->Active); |
63 | 63 | $transaction->commit(); |
64 | 64 | $this->assertFalse($transaction->Active); |
65 | - } |
|
66 | - catch(Exception $e) |
|
65 | + } catch(Exception $e) |
|
67 | 66 | { |
68 | 67 | $transaction->rollBack(); |
69 | 68 | $this->fail('Unexpected exception'); |
@@ -37,21 +37,21 @@ |
||
37 | 37 | |
38 | 38 | public function testActive() |
39 | 39 | { |
40 | - $this->assertFalse($this->_connection2->Active); |
|
40 | + $this->assertFalse($this->_connection2->Active); |
|
41 | 41 | |
42 | - $this->_connection2->Active=true; |
|
43 | - $this->assertTrue($this->_connection2->Active); |
|
44 | - $pdo=$this->_connection2->PdoInstance; |
|
45 | - $this->assertTrue($pdo instanceof PDO); |
|
46 | - // test setting Active repeatedly doesn't re-connect DB |
|
47 | - $this->_connection2->Active=true; |
|
48 | - $this->assertTrue($pdo===$this->_connection2->PdoInstance); |
|
42 | + $this->_connection2->Active=true; |
|
43 | + $this->assertTrue($this->_connection2->Active); |
|
44 | + $pdo=$this->_connection2->PdoInstance; |
|
45 | + $this->assertTrue($pdo instanceof PDO); |
|
46 | + // test setting Active repeatedly doesn't re-connect DB |
|
47 | + $this->_connection2->Active=true; |
|
48 | + $this->assertTrue($pdo===$this->_connection2->PdoInstance); |
|
49 | 49 | |
50 | 50 | $this->_connection2->Active=false; |
51 | - $this->assertFalse($this->_connection2->Active); |
|
51 | + $this->assertFalse($this->_connection2->Active); |
|
52 | 52 | |
53 | - try |
|
54 | - { |
|
53 | + try |
|
54 | + { |
|
55 | 55 | $connection=new TDbConnection('unknown:'.TEST_DB_FILE); |
56 | 56 | $connection->Active=true; |
57 | 57 | $this->fail('Expected exception is not raised'); |
@@ -2,10 +2,10 @@ discard block |
||
2 | 2 | |
3 | 3 | Prado::using('System.Data.*'); |
4 | 4 | |
5 | -if(!defined('TEST_DB_FILE')) |
|
6 | - define('TEST_DB_FILE',dirname(__FILE__).'/db/test.db'); |
|
7 | -if(!defined('TEST_DB_FILE2')) |
|
8 | - define('TEST_DB_FILE2',dirname(__FILE__).'/db/test2.db'); |
|
5 | +if (!defined('TEST_DB_FILE')) |
|
6 | + define('TEST_DB_FILE', dirname(__FILE__) . '/db/test.db'); |
|
7 | +if (!defined('TEST_DB_FILE2')) |
|
8 | + define('TEST_DB_FILE2', dirname(__FILE__) . '/db/test2.db'); |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * @package System.Data.PDO |
@@ -21,66 +21,66 @@ discard block |
||
21 | 21 | @unlink(TEST_DB_FILE2); |
22 | 22 | |
23 | 23 | // create application just to provide application mode |
24 | - new TApplication(__DIR__, false ,TApplication::CONFIG_TYPE_PHP); |
|
24 | + new TApplication(__DIR__, false, TApplication::CONFIG_TYPE_PHP); |
|
25 | 25 | |
26 | - $this->_connection1=new TDbConnection('sqlite:'.TEST_DB_FILE); |
|
27 | - $this->_connection1->Active=true; |
|
26 | + $this->_connection1 = new TDbConnection('sqlite:' . TEST_DB_FILE); |
|
27 | + $this->_connection1->Active = true; |
|
28 | 28 | $this->_connection1->createCommand('CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name VARCHAR(8))')->execute(); |
29 | - $this->_connection2=new TDbConnection('sqlite:'.TEST_DB_FILE2); |
|
29 | + $this->_connection2 = new TDbConnection('sqlite:' . TEST_DB_FILE2); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function tearDown() |
33 | 33 | { |
34 | - $this->_connection1=null; |
|
35 | - $this->_connection2=null; |
|
34 | + $this->_connection1 = null; |
|
35 | + $this->_connection2 = null; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function testActive() |
39 | 39 | { |
40 | 40 | $this->assertFalse($this->_connection2->Active); |
41 | 41 | |
42 | - $this->_connection2->Active=true; |
|
42 | + $this->_connection2->Active = true; |
|
43 | 43 | $this->assertTrue($this->_connection2->Active); |
44 | - $pdo=$this->_connection2->PdoInstance; |
|
44 | + $pdo = $this->_connection2->PdoInstance; |
|
45 | 45 | $this->assertTrue($pdo instanceof PDO); |
46 | 46 | // test setting Active repeatedly doesn't re-connect DB |
47 | - $this->_connection2->Active=true; |
|
48 | - $this->assertTrue($pdo===$this->_connection2->PdoInstance); |
|
47 | + $this->_connection2->Active = true; |
|
48 | + $this->assertTrue($pdo === $this->_connection2->PdoInstance); |
|
49 | 49 | |
50 | - $this->_connection2->Active=false; |
|
50 | + $this->_connection2->Active = false; |
|
51 | 51 | $this->assertFalse($this->_connection2->Active); |
52 | 52 | |
53 | 53 | try |
54 | 54 | { |
55 | - $connection=new TDbConnection('unknown:'.TEST_DB_FILE); |
|
56 | - $connection->Active=true; |
|
55 | + $connection = new TDbConnection('unknown:' . TEST_DB_FILE); |
|
56 | + $connection->Active = true; |
|
57 | 57 | $this->fail('Expected exception is not raised'); |
58 | 58 | } |
59 | - catch(TDbException $e) |
|
59 | + catch (TDbException $e) |
|
60 | 60 | { |
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | 64 | public function testCreateCommand() |
65 | 65 | { |
66 | - $sql='CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name VARCHAR(8))'; |
|
66 | + $sql = 'CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name VARCHAR(8))'; |
|
67 | 67 | try |
68 | 68 | { |
69 | 69 | $this->_connection2->createCommand($sql); |
70 | 70 | $this->fail('Expected exception is not raised'); |
71 | 71 | } |
72 | - catch(TDbException $e) |
|
72 | + catch (TDbException $e) |
|
73 | 73 | { |
74 | 74 | } |
75 | 75 | |
76 | - $command=$this->_connection1->createCommand($sql); |
|
76 | + $command = $this->_connection1->createCommand($sql); |
|
77 | 77 | $this->assertTrue($command instanceof TDbCommand); |
78 | 78 | } |
79 | 79 | |
80 | 80 | public function testBeginTransaction() |
81 | 81 | { |
82 | - $sql='INSERT INTO foo(id,name) VALUES (1,\'my name\')'; |
|
83 | - $transaction=$this->_connection1->beginTransaction(); |
|
82 | + $sql = 'INSERT INTO foo(id,name) VALUES (1,\'my name\')'; |
|
83 | + $transaction = $this->_connection1->beginTransaction(); |
|
84 | 84 | try |
85 | 85 | { |
86 | 86 | $this->_connection1->createCommand($sql)->execute(); |
@@ -88,40 +88,40 @@ discard block |
||
88 | 88 | $this->fail('Expected exception not raised'); |
89 | 89 | $transaction->commit(); |
90 | 90 | } |
91 | - catch(Exception $e) |
|
91 | + catch (Exception $e) |
|
92 | 92 | { |
93 | 93 | $transaction->rollBack(); |
94 | - $reader=$this->_connection1->createCommand('SELECT * FROM foo')->query(); |
|
94 | + $reader = $this->_connection1->createCommand('SELECT * FROM foo')->query(); |
|
95 | 95 | $this->assertFalse($reader->read()); |
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | 99 | public function testLastInsertID() |
100 | 100 | { |
101 | - $sql='INSERT INTO foo(name) VALUES (\'my name\')'; |
|
101 | + $sql = 'INSERT INTO foo(name) VALUES (\'my name\')'; |
|
102 | 102 | $this->_connection1->createCommand($sql)->execute(); |
103 | - $value=$this->_connection1->LastInsertID; |
|
104 | - $this->assertEquals($this->_connection1->LastInsertID,'1'); |
|
103 | + $value = $this->_connection1->LastInsertID; |
|
104 | + $this->assertEquals($this->_connection1->LastInsertID, '1'); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | public function testQuoteString() |
108 | 108 | { |
109 | - $str="this is 'my' name"; |
|
110 | - $expectedStr="'this is ''my'' name'"; |
|
111 | - $this->assertEquals($expectedStr,$this->_connection1->quoteString($str)); |
|
109 | + $str = "this is 'my' name"; |
|
110 | + $expectedStr = "'this is ''my'' name'"; |
|
111 | + $this->assertEquals($expectedStr, $this->_connection1->quoteString($str)); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | public function testColumnNameCase() |
115 | 115 | { |
116 | - $this->assertEquals(TDbColumnCaseMode::Preserved,$this->_connection1->ColumnCase); |
|
117 | - $this->_connection1->ColumnCase=TDbColumnCaseMode::LowerCase; |
|
118 | - $this->assertEquals(TDbColumnCaseMode::LowerCase,$this->_connection1->ColumnCase); |
|
116 | + $this->assertEquals(TDbColumnCaseMode::Preserved, $this->_connection1->ColumnCase); |
|
117 | + $this->_connection1->ColumnCase = TDbColumnCaseMode::LowerCase; |
|
118 | + $this->assertEquals(TDbColumnCaseMode::LowerCase, $this->_connection1->ColumnCase); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | public function testNullConversion() |
122 | 122 | { |
123 | - $this->assertEquals(TDbNullConversionMode::Preserved,$this->_connection1->NullConversion); |
|
124 | - $this->_connection1->NullConversion=TDbNullConversionMode::NullToEmptyString; |
|
125 | - $this->assertEquals(TDbNullConversionMode::NullToEmptyString,$this->_connection1->NullConversion); |
|
123 | + $this->assertEquals(TDbNullConversionMode::Preserved, $this->_connection1->NullConversion); |
|
124 | + $this->_connection1->NullConversion = TDbNullConversionMode::NullToEmptyString; |
|
125 | + $this->assertEquals(TDbNullConversionMode::NullToEmptyString, $this->_connection1->NullConversion); |
|
126 | 126 | } |
127 | 127 | } |
@@ -2,10 +2,12 @@ discard block |
||
2 | 2 | |
3 | 3 | Prado::using('System.Data.*'); |
4 | 4 | |
5 | -if(!defined('TEST_DB_FILE')) |
|
5 | +if(!defined('TEST_DB_FILE')) { |
|
6 | 6 | define('TEST_DB_FILE',dirname(__FILE__).'/db/test.db'); |
7 | -if(!defined('TEST_DB_FILE2')) |
|
7 | +} |
|
8 | +if(!defined('TEST_DB_FILE2')) { |
|
8 | 9 | define('TEST_DB_FILE2',dirname(__FILE__).'/db/test2.db'); |
10 | +} |
|
9 | 11 | |
10 | 12 | /** |
11 | 13 | * @package System.Data.PDO |
@@ -55,8 +57,7 @@ discard block |
||
55 | 57 | $connection=new TDbConnection('unknown:'.TEST_DB_FILE); |
56 | 58 | $connection->Active=true; |
57 | 59 | $this->fail('Expected exception is not raised'); |
58 | - } |
|
59 | - catch(TDbException $e) |
|
60 | + } catch(TDbException $e) |
|
60 | 61 | { |
61 | 62 | } |
62 | 63 | } |
@@ -68,8 +69,7 @@ discard block |
||
68 | 69 | { |
69 | 70 | $this->_connection2->createCommand($sql); |
70 | 71 | $this->fail('Expected exception is not raised'); |
71 | - } |
|
72 | - catch(TDbException $e) |
|
72 | + } catch(TDbException $e) |
|
73 | 73 | { |
74 | 74 | } |
75 | 75 | |
@@ -87,8 +87,7 @@ discard block |
||
87 | 87 | $this->_connection1->createCommand($sql)->execute(); |
88 | 88 | $this->fail('Expected exception not raised'); |
89 | 89 | $transaction->commit(); |
90 | - } |
|
91 | - catch(Exception $e) |
|
90 | + } catch(Exception $e) |
|
92 | 91 | { |
93 | 92 | $transaction->rollBack(); |
94 | 93 | $reader=$this->_connection1->createCommand('SELECT * FROM foo')->query(); |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | Prado::using('System.Data.*'); |
4 | 4 | |
5 | -if(!defined('TEST_DB_FILE')) |
|
6 | - define('TEST_DB_FILE',dirname(__FILE__).'/db/test.db'); |
|
5 | +if (!defined('TEST_DB_FILE')) |
|
6 | + define('TEST_DB_FILE', dirname(__FILE__) . '/db/test.db'); |
|
7 | 7 | |
8 | 8 | class FooRecord extends TComponent |
9 | 9 | { |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | public function __construct($param) |
15 | 15 | { |
16 | - $this->param=$param; |
|
16 | + $this->param = $param; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | public function getName() |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | public function setName($value) |
25 | 25 | { |
26 | - $this->_name=$value; |
|
26 | + $this->_name = $value; |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | @unlink(TEST_DB_FILE); |
40 | 40 | |
41 | 41 | // create application just to provide application mode |
42 | - new TApplication(__DIR__, false ,TApplication::CONFIG_TYPE_PHP); |
|
42 | + new TApplication(__DIR__, false, TApplication::CONFIG_TYPE_PHP); |
|
43 | 43 | |
44 | - $this->_connection=new TDbConnection('sqlite:'.TEST_DB_FILE); |
|
45 | - $this->_connection->Active=true; |
|
44 | + $this->_connection = new TDbConnection('sqlite:' . TEST_DB_FILE); |
|
45 | + $this->_connection->Active = true; |
|
46 | 46 | $this->_connection->createCommand('CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name VARCHAR(8))')->execute(); |
47 | 47 | $this->_connection->createCommand('INSERT INTO foo (name) VALUES (\'my name\')')->execute(); |
48 | 48 | $this->_connection->createCommand('INSERT INTO foo (name) VALUES (\'my name 2\')')->execute(); |
@@ -50,56 +50,56 @@ discard block |
||
50 | 50 | |
51 | 51 | public function tearDown() |
52 | 52 | { |
53 | - $this->_connection=null; |
|
53 | + $this->_connection = null; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | public function testRead() |
57 | 57 | { |
58 | - $reader=$this->_connection->createCommand('SELECT * FROM foo')->query(); |
|
59 | - $row=$reader->read(); |
|
60 | - $this->assertTrue($row['id']==='1' && $row['name']==='my name'); |
|
61 | - $row=$reader->read(); |
|
62 | - $this->assertTrue($row['id']==='2' && $row['name']==='my name 2'); |
|
63 | - $row=$reader->read(); |
|
58 | + $reader = $this->_connection->createCommand('SELECT * FROM foo')->query(); |
|
59 | + $row = $reader->read(); |
|
60 | + $this->assertTrue($row['id'] === '1' && $row['name'] === 'my name'); |
|
61 | + $row = $reader->read(); |
|
62 | + $this->assertTrue($row['id'] === '2' && $row['name'] === 'my name 2'); |
|
63 | + $row = $reader->read(); |
|
64 | 64 | $this->assertFalse($row); |
65 | 65 | } |
66 | 66 | |
67 | 67 | public function testReadColumn() |
68 | 68 | { |
69 | - $reader=$this->_connection->createCommand('SELECT * FROM foo')->query(); |
|
70 | - $this->assertEquals($reader->readColumn(0),'1'); |
|
71 | - $this->assertEquals($reader->readColumn(1),'my name 2'); |
|
69 | + $reader = $this->_connection->createCommand('SELECT * FROM foo')->query(); |
|
70 | + $this->assertEquals($reader->readColumn(0), '1'); |
|
71 | + $this->assertEquals($reader->readColumn(1), 'my name 2'); |
|
72 | 72 | $this->assertFalse($reader->readColumn(0)); |
73 | 73 | } |
74 | 74 | |
75 | 75 | public function testReadObject() |
76 | 76 | { |
77 | - $reader=$this->_connection->createCommand('SELECT * FROM foo')->query(); |
|
78 | - $object=$reader->readObject('FooRecord',array('object')); |
|
79 | - $this->assertEquals($object->id,'1'); |
|
80 | - $this->assertEquals($object->Name,'my name'); |
|
81 | - $this->assertEquals($object->param,'object'); |
|
77 | + $reader = $this->_connection->createCommand('SELECT * FROM foo')->query(); |
|
78 | + $object = $reader->readObject('FooRecord', array('object')); |
|
79 | + $this->assertEquals($object->id, '1'); |
|
80 | + $this->assertEquals($object->Name, 'my name'); |
|
81 | + $this->assertEquals($object->param, 'object'); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | public function testReadAll() |
85 | 85 | { |
86 | - $reader=$this->_connection->createCommand('SELECT * FROM foo')->query(); |
|
87 | - $rows=$reader->readAll(); |
|
88 | - $this->assertEquals(count($rows),2); |
|
89 | - $row=$rows[0]; |
|
90 | - $this->assertTrue($row['id']==='1' && $row['name']==='my name'); |
|
91 | - $row=$rows[1]; |
|
92 | - $this->assertTrue($row['id']==='2' && $row['name']==='my name 2'); |
|
93 | - |
|
94 | - $reader=$this->_connection->createCommand('SELECT * FROM foo WHERE id=3')->query(); |
|
95 | - $rows=$reader->readAll(); |
|
96 | - $this->assertEquals($rows,array()); |
|
86 | + $reader = $this->_connection->createCommand('SELECT * FROM foo')->query(); |
|
87 | + $rows = $reader->readAll(); |
|
88 | + $this->assertEquals(count($rows), 2); |
|
89 | + $row = $rows[0]; |
|
90 | + $this->assertTrue($row['id'] === '1' && $row['name'] === 'my name'); |
|
91 | + $row = $rows[1]; |
|
92 | + $this->assertTrue($row['id'] === '2' && $row['name'] === 'my name 2'); |
|
93 | + |
|
94 | + $reader = $this->_connection->createCommand('SELECT * FROM foo WHERE id=3')->query(); |
|
95 | + $rows = $reader->readAll(); |
|
96 | + $this->assertEquals($rows, array()); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | public function testClose() |
100 | 100 | { |
101 | - $reader=$this->_connection->createCommand('SELECT * FROM foo')->query(); |
|
102 | - $row=$reader->read(); |
|
101 | + $reader = $this->_connection->createCommand('SELECT * FROM foo')->query(); |
|
102 | + $row = $reader->read(); |
|
103 | 103 | $this->assertFalse($reader->IsClosed); |
104 | 104 | $reader->close(); |
105 | 105 | $this->assertTrue($reader->IsClosed); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $reader->read(); |
109 | 109 | $this->fail('Expected exception is not raised'); |
110 | 110 | } |
111 | - catch(Exception $e) |
|
111 | + catch (Exception $e) |
|
112 | 112 | { |
113 | 113 | } |
114 | 114 | } |
@@ -120,61 +120,61 @@ discard block |
||
120 | 120 | |
121 | 121 | public function testColumnCount() |
122 | 122 | { |
123 | - $reader=$this->_connection->createCommand('SELECT * FROM foo')->query(); |
|
124 | - $this->assertEquals($reader->ColumnCount,2); |
|
123 | + $reader = $this->_connection->createCommand('SELECT * FROM foo')->query(); |
|
124 | + $this->assertEquals($reader->ColumnCount, 2); |
|
125 | 125 | |
126 | - $reader=$this->_connection->createCommand('SELECT * FROM foo WHERE id=11')->query(); |
|
127 | - $this->assertEquals($reader->ColumnCount,2); |
|
126 | + $reader = $this->_connection->createCommand('SELECT * FROM foo WHERE id=11')->query(); |
|
127 | + $this->assertEquals($reader->ColumnCount, 2); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | public function testForeach() |
131 | 131 | { |
132 | - $ids=array(); |
|
133 | - $reader=$this->_connection->createCommand('SELECT * FROM foo')->query(); |
|
134 | - foreach($reader as $row) |
|
135 | - $ids[]=$row['id']; |
|
136 | - $this->assertEquals(count($ids),2); |
|
137 | - $this->assertTrue($ids[0]==='1' && $ids[1]==='2'); |
|
132 | + $ids = array(); |
|
133 | + $reader = $this->_connection->createCommand('SELECT * FROM foo')->query(); |
|
134 | + foreach ($reader as $row) |
|
135 | + $ids[] = $row['id']; |
|
136 | + $this->assertEquals(count($ids), 2); |
|
137 | + $this->assertTrue($ids[0] === '1' && $ids[1] === '2'); |
|
138 | 138 | |
139 | 139 | try |
140 | 140 | { |
141 | - foreach($reader as $row) |
|
142 | - $ids[]=$row['id']; |
|
141 | + foreach ($reader as $row) |
|
142 | + $ids[] = $row['id']; |
|
143 | 143 | $this->fail('Expected exception is not raised'); |
144 | 144 | } |
145 | - catch(TDbException $e) |
|
145 | + catch (TDbException $e) |
|
146 | 146 | { |
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | 150 | public function testFetchMode() |
151 | 151 | { |
152 | - $reader=$this->_connection->createCommand('SELECT * FROM foo')->query(); |
|
152 | + $reader = $this->_connection->createCommand('SELECT * FROM foo')->query(); |
|
153 | 153 | |
154 | - $reader->FetchMode=PDO::FETCH_NUM; |
|
155 | - $row=$reader->read(); |
|
154 | + $reader->FetchMode = PDO::FETCH_NUM; |
|
155 | + $row = $reader->read(); |
|
156 | 156 | $this->assertFalse(isset($row['id'])); |
157 | 157 | $this->assertTrue(isset($row[0])); |
158 | 158 | |
159 | - $reader->FetchMode=PDO::FETCH_ASSOC; |
|
160 | - $row=$reader->read(); |
|
159 | + $reader->FetchMode = PDO::FETCH_ASSOC; |
|
160 | + $row = $reader->read(); |
|
161 | 161 | $this->assertTrue(isset($row['id'])); |
162 | 162 | $this->assertFalse(isset($row[0])); |
163 | 163 | } |
164 | 164 | |
165 | 165 | public function testBindColumn() |
166 | 166 | { |
167 | - $reader=$this->_connection->createCommand('SELECT * FROM foo')->query(); |
|
168 | - $reader->bindColumn(1,$id); |
|
169 | - $reader->bindColumn(2,$name); |
|
167 | + $reader = $this->_connection->createCommand('SELECT * FROM foo')->query(); |
|
168 | + $reader->bindColumn(1, $id); |
|
169 | + $reader->bindColumn(2, $name); |
|
170 | 170 | $reader->read(); |
171 | - $this->assertEquals($id,'1'); |
|
172 | - $this->assertEquals($name,'my name'); |
|
171 | + $this->assertEquals($id, '1'); |
|
172 | + $this->assertEquals($name, 'my name'); |
|
173 | 173 | $reader->read(); |
174 | - $this->assertEquals($id,'2'); |
|
175 | - $this->assertEquals($name,'my name 2'); |
|
174 | + $this->assertEquals($id, '2'); |
|
175 | + $this->assertEquals($name, 'my name 2'); |
|
176 | 176 | $reader->read(); |
177 | - $this->assertEquals($id,'2'); |
|
178 | - $this->assertEquals($name,'my name 2'); |
|
177 | + $this->assertEquals($id, '2'); |
|
178 | + $this->assertEquals($name, 'my name 2'); |
|
179 | 179 | } |
180 | 180 | } |
@@ -2,8 +2,9 @@ discard block |
||
2 | 2 | |
3 | 3 | Prado::using('System.Data.*'); |
4 | 4 | |
5 | -if(!defined('TEST_DB_FILE')) |
|
5 | +if(!defined('TEST_DB_FILE')) { |
|
6 | 6 | define('TEST_DB_FILE',dirname(__FILE__).'/db/test.db'); |
7 | +} |
|
7 | 8 | |
8 | 9 | class FooRecord extends TComponent |
9 | 10 | { |
@@ -107,8 +108,7 @@ discard block |
||
107 | 108 | { |
108 | 109 | $reader->read(); |
109 | 110 | $this->fail('Expected exception is not raised'); |
110 | - } |
|
111 | - catch(Exception $e) |
|
111 | + } catch(Exception $e) |
|
112 | 112 | { |
113 | 113 | } |
114 | 114 | } |
@@ -131,18 +131,19 @@ discard block |
||
131 | 131 | { |
132 | 132 | $ids=array(); |
133 | 133 | $reader=$this->_connection->createCommand('SELECT * FROM foo')->query(); |
134 | - foreach($reader as $row) |
|
135 | - $ids[]=$row['id']; |
|
134 | + foreach($reader as $row) { |
|
135 | + $ids[]=$row['id']; |
|
136 | + } |
|
136 | 137 | $this->assertEquals(count($ids),2); |
137 | 138 | $this->assertTrue($ids[0]==='1' && $ids[1]==='2'); |
138 | 139 | |
139 | 140 | try |
140 | 141 | { |
141 | - foreach($reader as $row) |
|
142 | - $ids[]=$row['id']; |
|
142 | + foreach($reader as $row) { |
|
143 | + $ids[]=$row['id']; |
|
144 | + } |
|
143 | 145 | $this->fail('Expected exception is not raised'); |
144 | - } |
|
145 | - catch(TDbException $e) |
|
146 | + } catch(TDbException $e) |
|
146 | 147 | { |
147 | 148 | } |
148 | 149 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | |
4 | -if(!defined('PHPUnit_MAIN_METHOD')) { |
|
4 | +if (!defined('PHPUnit_MAIN_METHOD')) { |
|
5 | 5 | define('PHPUnit_MAIN_METHOD', 'Data_DataGateway_AllTests::main'); |
6 | 6 | } |
7 | 7 | |
@@ -22,6 +22,6 @@ discard block |
||
22 | 22 | } |
23 | 23 | } |
24 | 24 | |
25 | -if(PHPUnit_MAIN_METHOD == 'Data_DataGateway_AllTests::main') { |
|
25 | +if (PHPUnit_MAIN_METHOD == 'Data_DataGateway_AllTests::main') { |
|
26 | 26 | Data_DataGateway_AllTests::main(); |
27 | 27 | } |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | Prado::using('System.Data.*'); |
4 | 4 | |
5 | -if(!defined('TEST_DB_FILE')) |
|
6 | - define('TEST_DB_FILE',dirname(__FILE__).'/db/test.db'); |
|
5 | +if (!defined('TEST_DB_FILE')) |
|
6 | + define('TEST_DB_FILE', dirname(__FILE__) . '/db/test.db'); |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * @package System.Data.PDO |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | @unlink(TEST_DB_FILE); |
18 | 18 | |
19 | 19 | // create application just to provide application mode |
20 | - new TApplication(__DIR__, false ,TApplication::CONFIG_TYPE_PHP); |
|
20 | + new TApplication(__DIR__, false, TApplication::CONFIG_TYPE_PHP); |
|
21 | 21 | |
22 | - $this->_connection=new TDbConnection('sqlite:'.TEST_DB_FILE); |
|
23 | - $this->_connection->Active=true; |
|
22 | + $this->_connection = new TDbConnection('sqlite:' . TEST_DB_FILE); |
|
23 | + $this->_connection->Active = true; |
|
24 | 24 | $this->_connection->createCommand('CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name VARCHAR(8))')->execute(); |
25 | 25 | $this->_connection->createCommand('INSERT INTO foo (name) VALUES (\'my name\')')->execute(); |
26 | 26 | $this->_connection->createCommand('INSERT INTO foo (name) VALUES (\'my name 2\')')->execute(); |
@@ -28,116 +28,116 @@ discard block |
||
28 | 28 | |
29 | 29 | public function tearDown() |
30 | 30 | { |
31 | - $this->_connection=null; |
|
31 | + $this->_connection = null; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | public function testGetText() |
35 | 35 | { |
36 | - $sql='SELECT * FROM foo'; |
|
37 | - $command=$this->_connection->createCommand($sql); |
|
38 | - $this->assertEquals($command->Text,$sql); |
|
36 | + $sql = 'SELECT * FROM foo'; |
|
37 | + $command = $this->_connection->createCommand($sql); |
|
38 | + $this->assertEquals($command->Text, $sql); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | public function testSetText() |
42 | 42 | { |
43 | - $sql='SELECT name FROM foo'; |
|
44 | - $command=$this->_connection->createCommand($sql); |
|
45 | - $row=$command->query()->read(); |
|
46 | - $this->assertEquals($row['name'],'my name'); |
|
43 | + $sql = 'SELECT name FROM foo'; |
|
44 | + $command = $this->_connection->createCommand($sql); |
|
45 | + $row = $command->query()->read(); |
|
46 | + $this->assertEquals($row['name'], 'my name'); |
|
47 | 47 | |
48 | - $newSql='SELECT id FROM foo'; |
|
49 | - $command->Text=$newSql; |
|
50 | - $this->assertEquals($command->Text,$newSql); |
|
51 | - $row=$command->query()->read(); |
|
48 | + $newSql = 'SELECT id FROM foo'; |
|
49 | + $command->Text = $newSql; |
|
50 | + $this->assertEquals($command->Text, $newSql); |
|
51 | + $row = $command->query()->read(); |
|
52 | 52 | |
53 | - $this->assertEquals($row['id'],'1'); |
|
53 | + $this->assertEquals($row['id'], '1'); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | public function testConnection() |
57 | 57 | { |
58 | - $sql='SELECT name FROM foo'; |
|
59 | - $command=$this->_connection->createCommand($sql); |
|
58 | + $sql = 'SELECT name FROM foo'; |
|
59 | + $command = $this->_connection->createCommand($sql); |
|
60 | 60 | $this->assertTrue($command->Connection instanceof TDbConnection); |
61 | 61 | } |
62 | 62 | |
63 | 63 | public function testPrepare() |
64 | 64 | { |
65 | - $sql='SELECT name FROM foo'; |
|
66 | - $command=$this->_connection->createCommand($sql); |
|
67 | - $this->assertTrue($command->PdoStatement===null); |
|
65 | + $sql = 'SELECT name FROM foo'; |
|
66 | + $command = $this->_connection->createCommand($sql); |
|
67 | + $this->assertTrue($command->PdoStatement === null); |
|
68 | 68 | $command->prepare(); |
69 | 69 | $this->assertTrue($command->PdoStatement instanceof PDOStatement); |
70 | 70 | |
71 | 71 | try |
72 | 72 | { |
73 | - $command->Text='Bad SQL'; |
|
73 | + $command->Text = 'Bad SQL'; |
|
74 | 74 | $command->prepare(); |
75 | 75 | $this->fail('Expected exception is not raised'); |
76 | 76 | } |
77 | - catch(TDbException $e) |
|
77 | + catch (TDbException $e) |
|
78 | 78 | { |
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | 82 | public function testCancel() |
83 | 83 | { |
84 | - $sql='SELECT name FROM foo'; |
|
85 | - $command=$this->_connection->createCommand($sql); |
|
84 | + $sql = 'SELECT name FROM foo'; |
|
85 | + $command = $this->_connection->createCommand($sql); |
|
86 | 86 | $command->prepare(); |
87 | 87 | $this->assertTrue($command->PdoStatement instanceof PDOStatement); |
88 | 88 | $command->cancel(); |
89 | - $this->assertEquals($command->PdoStatement,null); |
|
89 | + $this->assertEquals($command->PdoStatement, null); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | public function testBindParameter() |
93 | 93 | { |
94 | - $sql='INSERT INTO foo (id,name) VALUES (3,:name)'; |
|
95 | - $command=$this->_connection->createCommand($sql); |
|
96 | - $name='new name'; |
|
97 | - $command->bindParameter(':name',$name); |
|
94 | + $sql = 'INSERT INTO foo (id,name) VALUES (3,:name)'; |
|
95 | + $command = $this->_connection->createCommand($sql); |
|
96 | + $name = 'new name'; |
|
97 | + $command->bindParameter(':name', $name); |
|
98 | 98 | $command->execute(); |
99 | - $insertedName=$this->_connection->createCommand('SELECT name FROM foo WHERE id=3')->queryScalar(); |
|
100 | - $this->assertEquals($name,$insertedName); |
|
99 | + $insertedName = $this->_connection->createCommand('SELECT name FROM foo WHERE id=3')->queryScalar(); |
|
100 | + $this->assertEquals($name, $insertedName); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | public function testBindValue() |
104 | 104 | { |
105 | - $sql='INSERT INTO foo (id,name) VALUES (3,:name)'; |
|
106 | - $command=$this->_connection->createCommand($sql); |
|
107 | - $command->bindValue(':name','new name'); |
|
105 | + $sql = 'INSERT INTO foo (id,name) VALUES (3,:name)'; |
|
106 | + $command = $this->_connection->createCommand($sql); |
|
107 | + $command->bindValue(':name', 'new name'); |
|
108 | 108 | $command->execute(); |
109 | - $insertedName=$this->_connection->createCommand('SELECT name FROM foo WHERE id=3')->queryScalar(); |
|
110 | - $this->assertEquals('new name',$insertedName); |
|
109 | + $insertedName = $this->_connection->createCommand('SELECT name FROM foo WHERE id=3')->queryScalar(); |
|
110 | + $this->assertEquals('new name', $insertedName); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | public function testExecute() |
114 | 114 | { |
115 | 115 | // test unprepared SQL execution |
116 | - $sql='INSERT INTO foo (name) VALUES (\'new name\')'; |
|
117 | - $command=$this->_connection->createCommand($sql); |
|
118 | - $n=$command->execute(); |
|
119 | - $this->assertEquals($n,1); |
|
116 | + $sql = 'INSERT INTO foo (name) VALUES (\'new name\')'; |
|
117 | + $command = $this->_connection->createCommand($sql); |
|
118 | + $n = $command->execute(); |
|
119 | + $this->assertEquals($n, 1); |
|
120 | 120 | $command->execute(); |
121 | - $count=$this->_connection->createCommand('SELECT COUNT(id) AS id_count FROM foo')->queryScalar(); |
|
122 | - $this->assertEquals('4',$count); |
|
121 | + $count = $this->_connection->createCommand('SELECT COUNT(id) AS id_count FROM foo')->queryScalar(); |
|
122 | + $this->assertEquals('4', $count); |
|
123 | 123 | |
124 | 124 | // test prepared SQL execution |
125 | - $sql='INSERT INTO foo (name) VALUES (\'new name\')'; |
|
126 | - $command=$this->_connection->createCommand($sql); |
|
125 | + $sql = 'INSERT INTO foo (name) VALUES (\'new name\')'; |
|
126 | + $command = $this->_connection->createCommand($sql); |
|
127 | 127 | $command->prepare(); |
128 | 128 | $command->execute(); |
129 | 129 | $command->execute(); |
130 | - $count=$this->_connection->createCommand('SELECT COUNT(id) AS id_count FROM foo')->queryScalar(); |
|
131 | - $this->assertEquals('6',$count); |
|
130 | + $count = $this->_connection->createCommand('SELECT COUNT(id) AS id_count FROM foo')->queryScalar(); |
|
131 | + $this->assertEquals('6', $count); |
|
132 | 132 | |
133 | 133 | // test exception raising |
134 | 134 | try |
135 | 135 | { |
136 | - $command=$this->_connection->createCommand('bad SQL'); |
|
136 | + $command = $this->_connection->createCommand('bad SQL'); |
|
137 | 137 | $command->execute(); |
138 | 138 | $this->fail('Expected exception is not raised'); |
139 | 139 | } |
140 | - catch(TDbException $e) |
|
140 | + catch (TDbException $e) |
|
141 | 141 | { |
142 | 142 | } |
143 | 143 | } |
@@ -145,25 +145,25 @@ discard block |
||
145 | 145 | public function testQuery() |
146 | 146 | { |
147 | 147 | // test unprepared SQL query |
148 | - $sql='SELECT * FROM foo'; |
|
149 | - $reader=$this->_connection->createCommand($sql)->query(); |
|
148 | + $sql = 'SELECT * FROM foo'; |
|
149 | + $reader = $this->_connection->createCommand($sql)->query(); |
|
150 | 150 | $this->assertTrue($reader instanceof TDbDataReader); |
151 | 151 | |
152 | 152 | // test unprepared SQL query |
153 | - $sql='SELECT * FROM foo'; |
|
154 | - $command=$this->_connection->createCommand($sql); |
|
153 | + $sql = 'SELECT * FROM foo'; |
|
154 | + $command = $this->_connection->createCommand($sql); |
|
155 | 155 | $command->prepare(); |
156 | - $reader=$command->query(); |
|
156 | + $reader = $command->query(); |
|
157 | 157 | $this->assertTrue($reader instanceof TDbDataReader); |
158 | 158 | |
159 | 159 | // test exception raising |
160 | 160 | try |
161 | 161 | { |
162 | - $command=$this->_connection->createCommand('bad SQL'); |
|
162 | + $command = $this->_connection->createCommand('bad SQL'); |
|
163 | 163 | $command->query(); |
164 | 164 | $this->fail('Expected exception is not raised'); |
165 | 165 | } |
166 | - catch(TDbException $e) |
|
166 | + catch (TDbException $e) |
|
167 | 167 | { |
168 | 168 | } |
169 | 169 | } |
@@ -171,25 +171,25 @@ discard block |
||
171 | 171 | public function testQueryRow() |
172 | 172 | { |
173 | 173 | // test unprepared SQL query |
174 | - $sql='SELECT * FROM foo'; |
|
175 | - $row=$this->_connection->createCommand($sql)->queryRow(); |
|
176 | - $this->assertTrue($row['id']==='1' && $row['name']==='my name'); |
|
174 | + $sql = 'SELECT * FROM foo'; |
|
175 | + $row = $this->_connection->createCommand($sql)->queryRow(); |
|
176 | + $this->assertTrue($row['id'] === '1' && $row['name'] === 'my name'); |
|
177 | 177 | |
178 | 178 | // test unprepared SQL query |
179 | - $sql='SELECT * FROM foo'; |
|
180 | - $command=$this->_connection->createCommand($sql); |
|
179 | + $sql = 'SELECT * FROM foo'; |
|
180 | + $command = $this->_connection->createCommand($sql); |
|
181 | 181 | $command->prepare(); |
182 | - $row=$command->queryRow(); |
|
183 | - $this->assertTrue($row['id']==='1' && $row['name']==='my name'); |
|
182 | + $row = $command->queryRow(); |
|
183 | + $this->assertTrue($row['id'] === '1' && $row['name'] === 'my name'); |
|
184 | 184 | |
185 | 185 | // test exception raising |
186 | 186 | try |
187 | 187 | { |
188 | - $command=$this->_connection->createCommand('bad SQL'); |
|
188 | + $command = $this->_connection->createCommand('bad SQL'); |
|
189 | 189 | $command->queryRow(); |
190 | 190 | $this->fail('Expected exception is not raised'); |
191 | 191 | } |
192 | - catch(TDbException $e) |
|
192 | + catch (TDbException $e) |
|
193 | 193 | { |
194 | 194 | } |
195 | 195 | } |
@@ -197,25 +197,25 @@ discard block |
||
197 | 197 | public function testQueryScalar() |
198 | 198 | { |
199 | 199 | // test unprepared SQL query |
200 | - $sql='SELECT * FROM foo'; |
|
201 | - $id=$this->_connection->createCommand($sql)->queryScalar(); |
|
202 | - $this->assertTrue($id==='1'); |
|
200 | + $sql = 'SELECT * FROM foo'; |
|
201 | + $id = $this->_connection->createCommand($sql)->queryScalar(); |
|
202 | + $this->assertTrue($id === '1'); |
|
203 | 203 | |
204 | 204 | // test unprepared SQL query |
205 | - $sql='SELECT * FROM foo'; |
|
206 | - $command=$this->_connection->createCommand($sql); |
|
205 | + $sql = 'SELECT * FROM foo'; |
|
206 | + $command = $this->_connection->createCommand($sql); |
|
207 | 207 | $command->prepare(); |
208 | - $row=$command->queryScalar(); |
|
209 | - $this->assertTrue($id==='1'); |
|
208 | + $row = $command->queryScalar(); |
|
209 | + $this->assertTrue($id === '1'); |
|
210 | 210 | |
211 | 211 | // test exception raising |
212 | 212 | try |
213 | 213 | { |
214 | - $command=$this->_connection->createCommand('bad SQL'); |
|
214 | + $command = $this->_connection->createCommand('bad SQL'); |
|
215 | 215 | $command->queryScalar(); |
216 | 216 | $this->fail('Expected exception is not raised'); |
217 | 217 | } |
218 | - catch(TDbException $e) |
|
218 | + catch (TDbException $e) |
|
219 | 219 | { |
220 | 220 | } |
221 | 221 | } |
@@ -2,8 +2,9 @@ discard block |
||
2 | 2 | |
3 | 3 | Prado::using('System.Data.*'); |
4 | 4 | |
5 | -if(!defined('TEST_DB_FILE')) |
|
5 | +if(!defined('TEST_DB_FILE')) { |
|
6 | 6 | define('TEST_DB_FILE',dirname(__FILE__).'/db/test.db'); |
7 | +} |
|
7 | 8 | |
8 | 9 | /** |
9 | 10 | * @package System.Data.PDO |
@@ -73,8 +74,7 @@ discard block |
||
73 | 74 | $command->Text='Bad SQL'; |
74 | 75 | $command->prepare(); |
75 | 76 | $this->fail('Expected exception is not raised'); |
76 | - } |
|
77 | - catch(TDbException $e) |
|
77 | + } catch(TDbException $e) |
|
78 | 78 | { |
79 | 79 | } |
80 | 80 | } |
@@ -136,8 +136,7 @@ discard block |
||
136 | 136 | $command=$this->_connection->createCommand('bad SQL'); |
137 | 137 | $command->execute(); |
138 | 138 | $this->fail('Expected exception is not raised'); |
139 | - } |
|
140 | - catch(TDbException $e) |
|
139 | + } catch(TDbException $e) |
|
141 | 140 | { |
142 | 141 | } |
143 | 142 | } |
@@ -162,8 +161,7 @@ discard block |
||
162 | 161 | $command=$this->_connection->createCommand('bad SQL'); |
163 | 162 | $command->query(); |
164 | 163 | $this->fail('Expected exception is not raised'); |
165 | - } |
|
166 | - catch(TDbException $e) |
|
164 | + } catch(TDbException $e) |
|
167 | 165 | { |
168 | 166 | } |
169 | 167 | } |
@@ -188,8 +186,7 @@ discard block |
||
188 | 186 | $command=$this->_connection->createCommand('bad SQL'); |
189 | 187 | $command->queryRow(); |
190 | 188 | $this->fail('Expected exception is not raised'); |
191 | - } |
|
192 | - catch(TDbException $e) |
|
189 | + } catch(TDbException $e) |
|
193 | 190 | { |
194 | 191 | } |
195 | 192 | } |
@@ -214,8 +211,7 @@ discard block |
||
214 | 211 | $command=$this->_connection->createCommand('bad SQL'); |
215 | 212 | $command->queryScalar(); |
216 | 213 | $this->fail('Expected exception is not raised'); |
217 | - } |
|
218 | - catch(TDbException $e) |
|
214 | + } catch(TDbException $e) |
|
219 | 215 | { |
220 | 216 | } |
221 | 217 | } |
@@ -15,18 +15,18 @@ |
||
15 | 15 | static $conn; |
16 | 16 | static $sqlMapManager; |
17 | 17 | |
18 | - if(Prado::getApplication() === null) |
|
19 | - Prado::setApplication(new TApplication(dirname(__FILE__).'/app')); |
|
18 | + if (Prado::getApplication() === null) |
|
19 | + Prado::setApplication(new TApplication(dirname(__FILE__) . '/app')); |
|
20 | 20 | |
21 | - if($conn === null) |
|
21 | + if ($conn === null) |
|
22 | 22 | $conn = new TDbConnection('mysql:host=localhost;dbname=prado_system_data_sqlmap', 'prado_unitest', 'prado_system_data_sqlmap_unitest'); |
23 | 23 | |
24 | 24 | $conn->setActive(true); |
25 | 25 | |
26 | - if($sqlMapManager === null) |
|
26 | + if ($sqlMapManager === null) |
|
27 | 27 | { |
28 | 28 | $sqlMapManager = new TSqlMapManager($conn); |
29 | - $sqlMapManager->configureXml( dirname(__FILE__) . '/DynamicParameterTestMap.xml'); |
|
29 | + $sqlMapManager->configureXml(dirname(__FILE__) . '/DynamicParameterTestMap.xml'); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | return $sqlMapManager; |
@@ -15,11 +15,13 @@ |
||
15 | 15 | static $conn; |
16 | 16 | static $sqlMapManager; |
17 | 17 | |
18 | - if(Prado::getApplication() === null) |
|
19 | - Prado::setApplication(new TApplication(dirname(__FILE__).'/app')); |
|
18 | + if(Prado::getApplication() === null) { |
|
19 | + Prado::setApplication(new TApplication(dirname(__FILE__).'/app')); |
|
20 | + } |
|
20 | 21 | |
21 | - if($conn === null) |
|
22 | - $conn = new TDbConnection('mysql:host=localhost;dbname=prado_system_data_sqlmap', 'prado_unitest', 'prado_system_data_sqlmap_unitest'); |
|
22 | + if($conn === null) { |
|
23 | + $conn = new TDbConnection('mysql:host=localhost;dbname=prado_system_data_sqlmap', 'prado_unitest', 'prado_system_data_sqlmap_unitest'); |
|
24 | + } |
|
23 | 25 | |
24 | 26 | $conn->setActive(true); |
25 | 27 |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | |
4 | -if(!defined('PHPUnit_MAIN_METHOD')) { |
|
4 | +if (!defined('PHPUnit_MAIN_METHOD')) { |
|
5 | 5 | define('PHPUnit_MAIN_METHOD', 'Data_SqlMap_AllTests::main'); |
6 | 6 | } |
7 | 7 | |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | $suite = new PHPUnit_Framework_TestSuite('System.Data.SqlMap'); |
19 | 19 | |
20 | 20 | $suite->addTestSuite('DynamicParameterTest'); |
21 | - $suite -> addTest( Data_SqlMap_DataMapper_AllTests::suite() ); |
|
21 | + $suite -> addTest(Data_SqlMap_DataMapper_AllTests::suite()); |
|
22 | 22 | |
23 | 23 | return $suite; |
24 | 24 | } |
25 | 25 | } |
26 | 26 | |
27 | -if(PHPUnit_MAIN_METHOD == 'Data_SqlMap_AllTests::main') { |
|
27 | +if (PHPUnit_MAIN_METHOD == 'Data_SqlMap_AllTests::main') { |
|
28 | 28 | Data_SqlMap_AllTests::main(); |
29 | 29 | } |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | |
239 | 239 | public function __set($name, $value) |
240 | 240 | { |
241 | - switch(strToLower($name)) |
|
241 | + switch (strToLower($name)) |
|
242 | 242 | { |
243 | 243 | case 'a': |
244 | 244 | $this -> _a = $value; |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | |
252 | 252 | public function __get($name) |
253 | 253 | { |
254 | - switch(strToLower($name)) |
|
254 | + switch (strToLower($name)) |
|
255 | 255 | { |
256 | 256 | case 'a': |
257 | 257 | return $this -> _a; |