예제 #1
0
 public function test_ignoring_last_insert_id_errors()
 {
     $conn = $this->getMock('PDO', array('lastInsertId'), array('sqlite::memory:'));
     $conn->exec('CREATE TABLE foo(id INTEGER PRIMARY KEY)');
     $conn->expects($this->any())->method('lastInsertId')->will($this->throwException(new \PDOException()));
     $mapper = new Mapper($conn);
     $obj = new \stdClass();
     $obj->id = null;
     $mapper->foo->persist($obj);
     $mapper->flush();
     //Ok, should not throw PDOException on this.
 }
예제 #2
0
 public function testeInflectedTypedEntityName()
 {
     $db = new Db($this->conn);
     $schema = new SchemaDecorators\Typed(new SchemaDecorators\Inflected(new Schemas\Infered()), __NAMESPACE__);
     $mapper = new Mapper($db, $schema);
     $c66 = $mapper->postCategory[66]->fetch();
     $this->assertInstanceOf(__NAMESPACE__ . '\\PostCategory', $c66);
     $this->assertObjectHasAttribute('postId', $c66);
     $c66->categoryId = 3;
     $mapper->persist($c66);
     $mapper->flush();
 }