예제 #1
0
 /**
  * @test
  */
 public function shouldGetValuesFromExternalTablesWhenUsingModel()
 {
     // given
     $city = new City();
     $city->deleteTableData();
     $person = new Person();
     $person->deleteTableData();
     $city->setZip(4330);
     $city->setCity('Aalgaard');
     $city->commit();
     $this->assertEquals(1, $this->getDb()->countRows("select zip from city where zip=?", array(4330)));
     $this->createPersons();
     // when
     $people = new People(4330);
     $values = $people->getValues();
     $first = $values[0];
     $this->log($values);
     $this->log($first);
     // then
     $this->assertEquals('John', $first['firstname']);
     $this->assertEquals('4330', $first['zip']);
     $this->assertEquals('Aalgaard', $first['city']);
 }
예제 #2
0
 /**
  * @test
  */
 public function shouldBeAbleToHaveJoins()
 {
     // given
     $person = new Person();
     if (!$person->exists()) {
         $person->createTable();
     }
     $person->deleteTableData();
     $person->setFirstname('John');
     $person->setZip('4330');
     $person->commit();
     $id = $person->getId();
     $city = new City();
     if (!$city->exists()) {
         $city->createTable();
     }
     $city->deleteTableData();
     $city->setZip(4330);
     $city->setCity('Algard');
     $city->commit();
     // when
     $person = new Person($id);
     // then
     $this->assertEquals($id, $person->getId());
     $this->assertEquals('4330', $person->getZip());
     $this->assertEquals('Algard', $person->getCity());
 }