public function testBatchSave() { $foo = new Foo; $foo->ID = 'SomeFoo'; // No foofoo -> invalid $bar = new Bar; $bar->ID = 'Somebar'; $bar->barbar = '...'; $bar->foo = $foo; try { DBModel::batchSave(array($foo, $bar)); $this->fail('Expected exception'); } catch (ValidationException $e) { $bar2 = Bar::get('Somebar'); $foo2 = Foo::get('SomeFoo'); $this->assertNull($bar2); $this->assertNull($foo2); $this->assertEquals('FooFoo is required', $foo->foofoo_error); } }
public function testBatchSave() { $nathan = new MockModel('nathan', null, '*****@*****.**'); $nathan->shadowProperty = 'Some Value'; $nathan->someRandomValue = 2; $nele = new MockModel('nele', null, '*****@*****.**'); $nele->shadowProperty = 'Some Value'; try { DBModel::batchSave(array($nathan, $nele)); $this->fail('Exception expected'); } catch (ValidationException $e) { $this->assertEquals('Integer is required', $nele->someRandomValue_error); $this->assertNull(MockModel::getByName('nathan')); } $nele->someRandomValue = 3; DBModel::batchSave(array($nathan, $nele)); $this->assertNotNull(MockModel::getByName('nathan')); $this->assertNotNull(MockModel::getByName('nele')); }