public function testGetAllMappings() { $expected_row = (object) array('id' => 123, 'uid' => $uid, 'jobid' => $jobid, 'start_time' => NULL, 'end_time' => NULL); $expected_mapping = new TZUserJobMapping($expected_row); $expected_mapping->setDBWrapper($this->dbWrapper); $expected_cursor = new stdClass(); $this->dbWrapper->expects($this->once())->method('query')->with('SELECT * FROM {tzusers_tzjobs} ORDER BY id')->will($this->returnValue($expected_cursor)); $this->dbWrapper->expects($this->exactly(2))->method('fetchObject')->with($expected_cursor)->will($this->onConsecutiveCalls($expected_row, NULL)); $mappings = $this->mapper->findAll(); $this->assertEquals(1, count($mappings)); $this->assertEquals($expected_mapping, $mappings[0]); }
function testCannotSaveWithInvertedInterval() { try { $expected_record = array('uid' => $this->expected_uid, 'jobid' => $this->expected_jobid, 'start_time' => 1308829978, 'end_time' => 1308825379); $mapping = new TZUserJobMapping($expected_record); $mapping->setDBWrapper($this->dbWrapper); $mapping->save(); $this->fail('should have received validation exception'); } catch (TZDBValidationException $e) { $expected_errors = array(t('Inverted interval')); $this->assertEquals($expected_errors, $e->getErrors()); } }