Пример #1
0
 public function testSave()
 {
     $everywhere = Location::find(1);
     $bulgaria = Location::findByName('Bulgaria');
     $children = $everywhere->getChildren()->add($bulgaria);
     Location::save($everywhere);
     $this->assertQueries(['SELECT Location.class, Location.* FROM Location WHERE (id = 1) LIMIT 1', 'SELECT Location.class, Location.* FROM Location WHERE (name = "Bulgaria") LIMIT 1', 'SELECT Location.class, Location.* FROM Location WHERE (parentId IN (1))', 'SELECT Location.class, Location.* FROM Location WHERE (path LIKE "1/3/10%")', 'UPDATE Location SET parentId = CASE id WHEN 10 THEN 1 ELSE parentId END, path = CASE id WHEN 11 THEN "1/10" ELSE path END WHERE (id IN (10, 11))']);
 }
Пример #2
0
 /**
  * @covers ::isRegion
  * @covers ::getRepo
  */
 public function testCity()
 {
     $eu = Location::find(2);
     $this->assertInstanceOf('Harp\\Locations\\Region', $eu);
     $this->assertTrue($eu->isRegion());
     $this->assertFalse($eu->isCity());
     $this->assertFalse($eu->isCountry());
 }
Пример #3
0
 /**
  * @covers ::isCountry
  * @covers ::getRepo
  */
 public function testCity()
 {
     $germany = Location::find(5);
     $this->assertInstanceOf('Harp\\Locations\\Country', $germany);
     $this->assertFalse($germany->isRegion());
     $this->assertFalse($germany->isCity());
     $this->assertTrue($germany->isCountry());
 }
Пример #4
0
 /**
  * @covers ::isCity
  * @covers ::getRepo
  */
 public function testCity()
 {
     $sofia = Location::find(11);
     $this->assertInstanceOf('Harp\\Locations\\City', $sofia);
     $this->assertFalse($sofia->isRegion());
     $this->assertTrue($sofia->isCity());
     $this->assertFalse($sofia->isCountry());
 }
Пример #5
0
 /**
  * @covers ::contains
  */
 public function testContains()
 {
     $everywhere = Location::find(1);
     $bulgaria = Location::findByName('Bulgaria');
     $sofia = Location::findByName('Sofia');
     $germany = Location::findByName('Germany');
     $this->assertTrue($everywhere->contains($everywhere));
     $this->assertTrue($everywhere->contains($bulgaria));
     $this->assertTrue($everywhere->contains($sofia));
     $this->assertTrue($bulgaria->contains($sofia));
     $this->assertFalse($germany->contains($sofia));
     $this->assertFalse($germany->contains($everywhere));
 }