public function testBatchCRUD() { $dogs = array(); for ($i = 0; $i < 3; $i++) { $s = new ParaObject(); $s->setType(self::dogsType); $s->foo = "bark!"; $dogs[$i] = $s; } $this->assertTrue(empty($this->pc->createAll(null))); $l1 = $this->pc->createAll($dogs); $this->assertEquals(3, sizeof($l1)); $this->assertNotNull($l1[0]->getId()); $this->assertTrue(empty($this->pc->readAll(null))); $nl = array(); $this->assertTrue(empty($this->pc->readAll($nl))); $nl[0] = $l1[0]->getId(); $nl[1] = $l1[1]->getId(); $nl[2] = $l1[2]->getId(); $l2 = $this->pc->readAll($nl); $this->assertEquals(3, sizeof($l2)); $this->assertEquals($l1[0]->getId(), $l2[0]->getId()); $this->assertEquals($l1[1]->getId(), $l2[1]->getId()); $this->assertTrue(isset($l2[0]->foo)); $this->assertEquals("bark!", $l2[0]->foo); $this->assertTrue(empty($this->pc->updateAll(null))); $part1 = new ParaObject($l1[0]->getId()); $part2 = new ParaObject($l1[1]->getId()); $part3 = new ParaObject($l1[2]->getId()); $part1->setType(self::dogsType); $part2->setType(self::dogsType); $part3->setType(self::dogsType); $part1->custom = "prop"; $part1->setName("NewName1"); $part2->setName("NewName2"); $part3->setName("NewName3"); $l3 = $this->pc->updateAll(array($part1, $part2, $part3)); $this->assertTrue(isset($l3[0]->custom)); $this->assertEquals(self::dogsType, $l3[0]->getType()); $this->assertEquals(self::dogsType, $l3[1]->getType()); $this->assertEquals(self::dogsType, $l3[2]->getType()); $this->assertEquals($part1->getName(), $l3[0]->getName()); $this->assertEquals($part2->getName(), $l3[1]->getName()); $this->assertEquals($part3->getName(), $l3[2]->getName()); $this->pc->deleteAll($nl); sleep(1); $l4 = $this->pc->listObjects(self::dogsType); $this->assertTrue(empty($l4)); $this->assertTrue(in_array(self::dogsType, $this->pc->getApp()->datatypes)); }