public function testFindOneOverDifferentConnections() { ORM::for_table('widget')->find_one(); $statementOne = ORM::get_last_statement(); $this->assertInstanceOf('MockPDOStatement', $statementOne); ORM::for_table('person', self::ALTERNATE)->find_one(); $statementOne = ORM::get_last_statement(); // get_statement is *not* per connection $this->assertInstanceOf('MockDifferentPDOStatement', $statementOne); $expected = "SELECT * FROM `widget` LIMIT 1"; $this->assertNotEquals($expected, ORM::get_last_query()); // Because get_last_query() is across *all* connections $this->assertEquals($expected, ORM::get_last_query(ORM::DEFAULT_CONNECTION)); $expectedToo = "SELECT * FROM `person` LIMIT 1"; $this->assertEquals($expectedToo, ORM::get_last_query(self::ALTERNATE)); }
public function testGetLastPdoStatement() { ORM::for_table('widget')->where('name', 'Fred')->find_one(); $statement = ORM::get_last_statement(); $this->assertInstanceOf('MockPDOStatement', $statement); }