Exemplo n.º 1
0
 /**
  * Will we properly try to call the right magic method?
  *
  * @dataProvider dataMagic
  * @param string $method
  */
 public function testMagic($method)
 {
     $testOne = new Test_One();
     $friend = new Friend($testOne);
     $badMethod = false;
     $exception = null;
     try {
         switch ($method) {
             case '__call':
                 $friend->someMethod();
                 break;
             case '__get':
                 $friend->someProperty;
                 break;
             case '__isset':
                 isset($friend->someProperty);
                 break;
             case '__set':
                 $friend->someProperty = 12;
                 break;
             case '__unset':
                 unset($friend->someProperty);
                 break;
             default:
                 $badMethod = true;
         }
     } catch (Exception $ex) {
         $exception = $ex;
     }
     if ($badMethod) {
         $this->fail('Unexpected magic method: ' . $method);
     }
     if (is_null($exception)) {
         $this->fail('Method did not throw an exception');
     }
     $message = $exception->getMessage();
     $this->assertEquals('magic ' . $method, $message, 'Method did not throw expected message: ' . $message);
 }