예제 #1
0
파일: 969TestCase.php 프로젝트: swk/bluebox
 public function prepareData()
 {
     $d = new T1();
     $d->t1_id = 1;
     $d->t2_id = 1;
     $d->save();
     $d = new T2();
     $d->t2_id = 1;
     $d->hello_id = 10;
     $d->save();
     for ($i = 0; $i < 10; $i++) {
         $t3 = new T3();
         $t3->hello_id = 10;
         $t3->save();
     }
 }
 /**
  * need prior saving of row to test unique values.
  *
  * @depends testSuccessfulSaveInStrictSQLMode
  */
 public function testForUnique()
 {
     $t1 = new T1();
     $t1->set_attributes(Data::$dataForNotNullColumnsArray);
     $t1->set_attributes(Data::$dataStrictSQLValidForNotNullColumnsArray);
     $t1->col_int1 = 1;
     $result = $t1->save();
     $this->assertTrue(array_key_exists('col_int1', $t1->errors->get_raw_errors()));
     $t1->col_integer1 = 2;
     $t1->col_integer3 = 3;
     $result = $t1->save();
     $result = array_key_exists('col_integer1_and_col_integer3', $t1->errors->get_raw_errors());
     $this->assertTrue($result);
 }
 public function testDefaultValues()
 {
     $t1 = new T1();
     $t1->attributes = Data::$dataForNotNullColumnsArray;
     $t1->attributes = Data::$dataDefaultSQLValidForNotNullColumnsArray;
     $t1->attributes = Data::$dataStrictSQLValidForNotNullColumnsArray;
     $result = $t1->save();
     $this->assertTrue($result);
     foreach (Data::$dataForColumnsWithDefaultValuesArray as $columnName => $defaulValue) {
         $this->assertEquals($t1->{$columnName}, $defaulValue);
     }
 }