Beispiel #1
0
 public function testSetData()
 {
     $page = new Page(new Request());
     $page->setData('place', 'Norway');
     $page->setData(['city' => 'Oslo', 'height' => 12]);
     $ref_data = new \ReflectionProperty($page, '_data');
     $ref_data->setAccessible(true);
     $expected = ['place' => 'Norway', 'city' => 'Oslo', 'height' => 12];
     $result = $ref_data->getvalue($page);
     $this->assertEquals($expected, $result);
 }
Beispiel #2
0
 /**
  * Reflects a property and provides resolution callable
  *
  * @access private
  * @return void
  */
 private function reflectProperty()
 {
     list($class, $property) = explode('::', $this->value);
     $this->class = ltrim($class, '\\');
     $this->property = ltrim($property, '\\$');
     $this->isProperty = TRUE;
     try {
         $reflection = new \ReflectionProperty($this->class, $this->property);
         if (!$reflection->isPublic()) {
             $reflection->setAccessible(TRUE);
         }
         if ($reflection->isStatic()) {
             $this->call = function () use($reflection) {
                 return $reflection->getValue();
             };
         } else {
             $this->needsObject = TRUE;
             $this->call = function ($object) use($reflection) {
                 return $reflection->getvalue($object);
             };
         }
     } catch (\ReflectionException $e) {
         throw new InvalidTestException(sprintf('Cannot assert or reject undefined property "%s" on class "%s"', $this->property, $this->class));
     }
 }