@@ -220,6 +220,7 @@ class DboPostgresTest extends CakeTestCase {
220
220
*/
221
221
var $ fixtures = array ('core.user ' , 'core.binary_test ' , 'core.comment ' , 'core.article ' ,
222
222
'core.tag ' , 'core.articles_tag ' , 'core.attachment ' , 'core.person ' , 'core.post ' , 'core.author ' ,
223
+ 'core.datatype ' ,
223
224
);
224
225
/**
225
226
* Actual DB connection used in testing
@@ -437,6 +438,17 @@ function testBooleanNormalization() {
437
438
$ this ->assertFalse ($ this ->db2 ->boolean ('' ));
438
439
}
439
440
441
+ /**
442
+ * test that default -> false in schemas works correctly.
443
+ *
444
+ * @return void
445
+ */
446
+ function testBooleanDefaultFalseInSchema () {
447
+ $ model = new Model (array ('name ' => 'Datatype ' , 'table ' => 'datatypes ' , 'ds ' => 'test_suite ' ));
448
+ $ model ->create ();
449
+ $ this ->assertIdentical (false , $ model ->data ['Datatype ' ]['bool ' ]);
450
+ }
451
+
440
452
/**
441
453
* testLastInsertIdMultipleInsert method
442
454
*
@@ -446,23 +458,15 @@ function testBooleanNormalization() {
446
458
function testLastInsertIdMultipleInsert () {
447
459
$ db1 = ConnectionManager::getDataSource ('test_suite ' );
448
460
449
- if (PHP5 ) {
450
- $ db2 = clone $ db1 ;
451
- } else {
452
- $ db2 = $ db1 ;
453
- }
454
-
455
- $ db2 ->connect ();
456
- $ this ->assertNotEqual ($ db1 ->connection , $ db2 ->connection );
457
-
458
461
$ table = $ db1 ->fullTableName ('users ' , false );
459
462
$ password = '5f4dcc3b5aa765d61d8327deb882cf99 ' ;
460
463
$ db1 ->execute (
461
464
"INSERT INTO {$ table } ( \"user \", password) VALUES ('mariano', ' {$ password }') "
462
465
);
463
- $ db2 ->execute ("INSERT INTO {$ table } ( \"user \", password) VALUES ('hoge', ' {$ password }') " );
464
466
$ this ->assertEqual ($ db1 ->lastInsertId ($ table ), 1 );
465
- $ this ->assertEqual ($ db2 ->lastInsertId ($ table ), 2 );
467
+
468
+ $ db1 ->execute ("INSERT INTO {$ table } ( \"user \", password) VALUES ('hoge', ' {$ password }') " );
469
+ $ this ->assertEqual ($ db1 ->lastInsertId ($ table ), 2 );
466
470
}
467
471
468
472
/**
@@ -582,39 +586,38 @@ function testCakeSchema() {
582
586
$ db1 =& ConnectionManager::getDataSource ('test_suite ' );
583
587
$ db1 ->cacheSources = false ;
584
588
$ db1 ->reconnect (array ('persistent ' => false ));
585
- $ db1 ->query ('CREATE TABLE ' . $ db1 ->fullTableName ('datatypes ' ) . ' (
589
+ $ db1 ->query ('CREATE TABLE ' . $ db1 ->fullTableName ('datatype_tests ' ) . ' (
586
590
id serial NOT NULL,
587
591
"varchar" character varying(40) NOT NULL,
588
592
"full_length" character varying NOT NULL,
589
593
"timestamp" timestamp without time zone,
590
594
date date,
591
595
CONSTRAINT test_suite_data_types_pkey PRIMARY KEY (id)
592
596
) ' );
593
- $ model = new Model (array ('name ' => 'Datatype ' , 'ds ' => 'test_suite ' ));
597
+ $ model = new Model (array ('name ' => 'DatatypeTest ' , 'ds ' => 'test_suite ' ));
594
598
$ schema = new CakeSchema (array ('connection ' => 'test_suite ' ));
595
599
$ result = $ schema ->read (array (
596
600
'connection ' => 'test_suite ' ,
597
- 'models ' => array ('Datatype ' )
598
601
));
599
- $ schema ->tables = array ('datatypes ' => $ result ['tables ' ]['datatypes ' ]);
600
- $ result = $ db1 ->createSchema ($ schema , 'datatypes ' );
602
+ $ schema ->tables = array ('datatype_tests ' => $ result ['tables ' ]['missing ' ][ ' datatype_tests ' ]);
603
+ $ result = $ db1 ->createSchema ($ schema , 'datatype_tests ' );
601
604
602
605
$ this ->assertNoPattern ('/timestamp DEFAULT/ ' , $ result );
603
606
$ this ->assertPattern ('/\"full_length\"\s*text\s.*,/ ' , $ result );
604
607
$ this ->assertPattern ('/timestamp\s*,/ ' , $ result );
605
608
606
- $ db1 ->query ('DROP TABLE ' . $ db1 ->fullTableName ('datatypes ' ));
609
+ $ db1 ->query ('DROP TABLE ' . $ db1 ->fullTableName ('datatype_tests ' ));
607
610
608
611
$ db1 ->query ($ result );
609
612
$ result2 = $ schema ->read (array (
610
613
'connection ' => 'test_suite ' ,
611
- 'models ' => array ('Datatype ' )
614
+ 'models ' => array ('DatatypeTest ' )
612
615
));
613
- $ schema ->tables = array ('datatypes ' => $ result2 ['tables ' ]['datatypes ' ]);
614
- $ result2 = $ db1 ->createSchema ($ schema , 'datatypes ' );
616
+ $ schema ->tables = array ('datatype_tests ' => $ result2 ['tables ' ]['missing ' ][ ' datatype_tests ' ]);
617
+ $ result2 = $ db1 ->createSchema ($ schema , 'datatype_tests ' );
615
618
$ this ->assertEqual ($ result , $ result2 );
616
619
617
- $ db1 ->query ('DROP TABLE ' . $ db1 ->fullTableName ('datatypes ' ));
620
+ $ db1 ->query ('DROP TABLE ' . $ db1 ->fullTableName ('datatype_tests ' ));
618
621
}
619
622
620
623
/**
0 commit comments