1
0
mirror of synced 2024-12-13 14:56:01 +03:00
doctrine2/tests/ConfigurableTestCase.php

102 lines
4.1 KiB
PHP
Raw Normal View History

2006-04-14 00:37:28 +04:00
<?php
require_once("UnitTestCase.php");
2006-04-14 00:37:28 +04:00
class Doctrine_ConfigurableTestCase extends Doctrine_UnitTestCase {
public function prepareTables() { }
public function prepareData() { }
2006-04-14 00:37:28 +04:00
public function testSetAttribute() {
2006-08-22 03:20:33 +04:00
$table = $this->connection->getTable("User");
2006-04-14 00:37:28 +04:00
$this->manager->setAttribute(Doctrine::ATTR_CACHE_TTL,100);
$this->assertEqual($this->manager->getAttribute(Doctrine::ATTR_CACHE_TTL),100);
$this->manager->setAttribute(Doctrine::ATTR_CACHE_SIZE,1);
$this->assertEqual($this->manager->getAttribute(Doctrine::ATTR_CACHE_SIZE),1);
$this->manager->setAttribute(Doctrine::ATTR_CACHE_DIR,"%ROOT%".DIRECTORY_SEPARATOR."cache");
$this->assertEqual($this->manager->getAttribute(Doctrine::ATTR_CACHE_DIR),$this->manager->getRoot().DIRECTORY_SEPARATOR."cache");
$this->manager->setAttribute(Doctrine::ATTR_FETCHMODE,Doctrine::FETCH_LAZY);
$this->assertEqual($this->manager->getAttribute(Doctrine::ATTR_FETCHMODE),Doctrine::FETCH_LAZY);
$this->manager->setAttribute(Doctrine::ATTR_BATCH_SIZE, 5);
$this->assertEqual($this->manager->getAttribute(Doctrine::ATTR_BATCH_SIZE),5);
2006-06-03 13:10:43 +04:00
$this->manager->setAttribute(Doctrine::ATTR_LISTENER, new Doctrine_EventListener_Debugger());
$this->assertTrue($this->manager->getAttribute(Doctrine::ATTR_LISTENER) instanceof Doctrine_EventListener_Debugger);
2006-04-14 00:37:28 +04:00
$this->manager->setAttribute(Doctrine::ATTR_PK_COLUMNS, array("id"));
$this->assertEqual($this->manager->getAttribute(Doctrine::ATTR_PK_COLUMNS), array("id"));
$this->manager->setAttribute(Doctrine::ATTR_PK_TYPE, Doctrine::INCREMENT_KEY);
$this->assertEqual($this->manager->getAttribute(Doctrine::ATTR_PK_TYPE), Doctrine::INCREMENT_KEY);
$this->manager->setAttribute(Doctrine::ATTR_LOCKMODE, Doctrine::LOCK_PESSIMISTIC);
$this->assertEqual($this->manager->getAttribute(Doctrine::ATTR_LOCKMODE), Doctrine::LOCK_PESSIMISTIC);
// test invalid arguments
try {
$this->manager->setAttribute(Doctrine::ATTR_CACHE_TTL,-12);
} catch(Exception $e) {
$this->assertTrue($e instanceof Exception);
}
try {
$this->manager->setAttribute(Doctrine::ATTR_CACHE_SIZE,-12);
} catch(Exception $e) {
$this->assertTrue($e instanceof Exception);
}
try {
$this->manager->setAttribute(Doctrine::ATTR_BATCH_SIZE,-12);
} catch(Exception $e) {
$this->assertTrue($e instanceof Exception);
}
try {
2006-08-22 03:20:33 +04:00
$this->connection->beginTransaction();
2006-04-14 00:37:28 +04:00
$this->manager->setAttribute(Doctrine::ATTR_LOCKMODE, Doctrine::LOCK_OPTIMISTIC);
} catch(Exception $e) {
$this->assertTrue($e instanceof Exception);
2006-08-22 03:20:33 +04:00
$this->connection->commit();
2006-04-14 00:37:28 +04:00
}
2006-04-17 00:38:17 +04:00
$e = false;
try {
$this->manager->setAttribute(Doctrine::ATTR_COLL_KEY, "name");
} catch(Exception $e) {
}
$this->assertTrue($e instanceof Exception);
$e = false;
try {
$table->setAttribute(Doctrine::ATTR_COLL_KEY, "unknown");
2006-04-17 00:38:17 +04:00
} catch(Exception $e) {
}
$this->assertTrue($e instanceof Exception);
$e = true;
try {
$table->setAttribute(Doctrine::ATTR_COLL_KEY, "name");
2006-04-17 00:38:17 +04:00
} catch(Exception $e) {
}
$this->assertTrue($e);
$e = false;
2006-04-14 00:37:28 +04:00
try {
2006-08-22 03:20:33 +04:00
$this->connection->beginTransaction();
$this->connection->setAttribute(Doctrine::ATTR_LOCKMODE, Doctrine::LOCK_PESSIMISTIC);
2006-04-14 00:37:28 +04:00
} catch(Exception $e) {
$this->assertTrue($e instanceof Exception);
2006-08-22 03:20:33 +04:00
$this->connection->commit();
2006-04-14 00:37:28 +04:00
}
try {
$this->manager->setAttribute(Doctrine::ATTR_PK_TYPE,-12);
} catch(Exception $e) {
$this->assertTrue($e instanceof Exception);
}
}
public function testGetAttributes() {
$this->assertTrue(is_array($this->manager->getAttributes()));
}
}
?>