Example #1
0
 public function testVariableSetterMethods()
 {
     // instantiation
     $v = array('one' => 1);
     $q = new Query("SELECT %one:int%", $v);
     // test getter
     $this->assertSame($q->one, 1);
     $this->assertSame($q->dataGet(), $v);
     // test setter
     $q->one = 2;
     $this->assertSame($q->one, 2);
     // test isset
     $this->assertTrue(isset($q->one));
     $this->assertFalse(isset($q->two));
     // test unset
     unset($q->one);
     $this->assertFalse(isset($q->one));
     $this->assertSame($q->dataGet(), []);
     // test addition
     $q->two = 2;
     $this->assertSame($q->two, 2);
     // test wholesale replace
     $newData = array('three' => 3);
     $this->assertSame($q->dataSet($newData), $q);
     $this->assertSame($q->dataGet(), $newData);
     // handling null
     $q->null = null;
     $this->assertSame($q->null, null);
     $this->setExpectedException('Bond\\Exception\\BadPropertyException');
     $q->thisPropertyDoesNotExist;
 }