CubridActiveRecordTest.php 986 Bytes
Newer Older
Carsten Brandt committed
1 2 3
<?php
namespace yiiunit\framework\db\cubrid;

4
use yiiunit\data\ar\Customer;
Carsten Brandt committed
5 6
use yiiunit\framework\db\ActiveRecordTest;

7 8 9 10
/**
 * @group db
 * @group cubrid
 */
Carsten Brandt committed
11 12
class CubridActiveRecordTest extends ActiveRecordTest
{
Carsten Brandt committed
13
	public $driverName = 'cubrid';
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34

	/**
	 * 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);
35

Alexander Makarov committed
36
		$customers = Customer::find()->where(['status' => true])->all();
37 38
		$this->assertEquals(2, count($customers));

Alexander Makarov committed
39
		$customers = Customer::find()->where(['status' => false])->all();
40
		$this->assertEquals(1, count($customers));
41
	}
Carsten Brandt committed
42
}