Beispiel #1
0
 /**
  * Test behavior of magic method during a state's method calling.
  */
 public function testGetIssetSetUnsetPublicByMethod()
 {
     //Test defined property
     $this->initializeProxy('state1', true);
     $this->assertEquals('value1', $this->proxy->getPublicProperty());
     $this->assertTrue($this->proxy->issetPublicProperty());
     $this->proxy->setPublicProperty('value2');
     $this->assertEquals('value2', $this->proxy->getPublicProperty());
     $this->proxy->unsetPublicProperty();
     //Test missing property
     $this->assertFalse($this->proxy->issetMissingPublicProperty());
     $fail = false;
     try {
         $a = $this->proxy->getOnMissingPublicProperty();
     } catch (\Throwable $e) {
         $fail = true;
     }
     if (false === $fail) {
         $this->fail('Error __get must throw an exception for missing property');
     }
     $this->proxy->setOnMissingPublicProperty('fooBar');
     $this->assertTrue($this->proxy->issetMissingPublicProperty());
     $this->assertEquals('fooBar', $this->proxy->getOnMissingPublicProperty());
     $this->proxy->unsetOnMissingPublicProperty();
     $this->assertFalse($this->proxy->issetMissingPublicProperty());
     $fail = false;
     try {
         $a = $this->proxy->getOnMissingPublicProperty();
     } catch (\Throwable $e) {
         $fail = true;
     }
     if (false === $fail) {
         $this->fail('Error __get must throw an exception for missing property');
     }
 }