Browse Source

moved unit test from cubrid to general

should be tested for all dbms not only cubrid even if the problem may
not exist in all of them it is good to verify that.
tags/2.0.0-beta
Carsten Brandt 11 years ago
parent
commit
e5a1244e0f
  1. 28
      tests/unit/framework/db/ActiveRecordTest.php
  2. 28
      tests/unit/framework/db/cubrid/CubridActiveRecordTest.php

28
tests/unit/framework/db/ActiveRecordTest.php

@ -426,4 +426,32 @@ class ActiveRecordTest extends DatabaseTestCase
$this->assertEquals(0, $record->var3); $this->assertEquals(0, $record->var3);
$this->assertEquals('', $record->stringcol); $this->assertEquals('', $record->stringcol);
} }
/**
* Some PDO implementations(e.g. cubrid) do not support boolean values.
* Make sure this does not affect AR layer.
*/
public function testBooleanAttribute()
{
$customer = new Customer();
$customer->name = 'boolean customer';
$customer->email = 'mail@example.com';
$customer->status = true;
$customer->save(false);
$customer->refresh();
$this->assertEquals(1, $customer->status);
$customer->status = false;
$customer->save(false);
$customer->refresh();
$this->assertEquals(0, $customer->status);
$customers = Customer::find()->where(['status' => true])->all();
$this->assertEquals(2, count($customers));
$customers = Customer::find()->where(['status' => false])->all();
$this->assertEquals(1, count($customers));
}
} }

28
tests/unit/framework/db/cubrid/CubridActiveRecordTest.php

@ -11,32 +11,4 @@ use yiiunit\framework\db\ActiveRecordTest;
class CubridActiveRecordTest extends ActiveRecordTest class CubridActiveRecordTest extends ActiveRecordTest
{ {
public $driverName = 'cubrid'; public $driverName = 'cubrid';
/**
* cubrid PDO does not support boolean values.
* Make sure this does not affect AR layer.
*/
public function testBooleanAttribute()
{
$customer = new Customer();
$customer->name = 'boolean customer';
$customer->email = 'mail@example.com';
$customer->status = true;
$customer->save(false);
$customer->refresh();
$this->assertEquals(1, $customer->status);
$customer->status = false;
$customer->save(false);
$customer->refresh();
$this->assertEquals(0, $customer->status);
$customers = Customer::find()->where(['status' => true])->all();
$this->assertEquals(2, count($customers));
$customers = Customer::find()->where(['status' => false])->all();
$this->assertEquals(1, count($customers));
}
} }

Loading…
Cancel
Save