public function testNewTrade() { $date = '2013-07-17'; $no = 12345; // Delete if it exists Trade::objects()->filter('tradedate', '=', $date)->filter('tradeno', '=', $no)->delete(); $t = new Trade(); $t->tradedate = $date; $t->tradeno = $no; $t->price = 123.45; $t->quantity = 321; // Check insert does not change the object $t0 = clone $t; $t->insert(); $this->assertEquals($t, $t0); // Load it from the database $t2 = Trade::get($date, $no); $this->assertInstanceOf("Phormium\\Tests\\Models\\Trade", $t2); $this->assertEquals($t, $t2); // Alternative get $t3 = Trade::get(array($date, $no)); $this->assertInstanceOf("Phormium\\Tests\\Models\\Trade", $t3); $this->assertEquals($t, $t3); }
/** * @expectedException \Exception * @expectedExceptionMessage Error forming aggregate query. Column [xxx] does not exist in table [trade]. */ public function testInvalidColumn() { Trade::objects()->avg('xxx'); }