Example #1
0
 public function testHandleError()
 {
     $this->setExpectedException('\\ErrorException');
     Shunt::handleError(999, 'Something goes wrong', __FILE__, 56, array());
 }
Example #2
0
 /**
  * @{inheritDoc}
  */
 public function collectData()
 {
     $recipes = $this->recipes;
     // @codeCoverageIgnoreStart
     if (empty($recipes)) {
         $currentDir = isset($_SERVER['PWD']) ? realpath($_SERVER['PWD']) : getcwd();
         if (($holder = $currentDir . DIRECTORY_SEPARATOR . Shunt::holder()) && @file_exists($holder)) {
             $recipes = (include $holder);
         }
     }
     // @codeCoverageIgnoreEnd
     // Set the hosts
     if (array_key_exists(Shunt::KEY_HOSTS, $recipes)) {
         foreach ($recipes[Shunt::KEY_HOSTS] as $nickServer => $server) {
             $this->setHost($nickServer, $server);
         }
     }
     // Set the auth credential
     if (array_key_exists(Shunt::KEY_AUTH, $recipes)) {
         $credential = array_filter($recipes[Shunt::KEY_AUTH]);
         // @codeCoverageIgnoreStart
         if (array_key_exists(Shunt::KEY_AUTH_PASSWORD, $credential)) {
             $this->setAuth(Auth::PASSWORD, $credential);
         } elseif (array_key_exists(Shunt::KEY_AUTH_PUBKEY, $credential) && array_key_exists(Shunt::KEY_AUTH_PRIVKEY, $credential)) {
             $this->setAuth(Auth::PUBKEY_FILE, $credential);
         }
         // @codeCoverageIgnoreEnd
     }
     // Set the available tasks
     if (array_key_exists(Shunt::KEY_TASKS, $recipes)) {
         foreach ($recipes[Shunt::KEY_TASKS] as $taskName => $taskFunction) {
             // Validate each task
             if ($taskFunction instanceof Closure) {
                 $taskInformation = ReflectionFunction::export($recipes[Shunt::KEY_TASKS][$taskName], TRUE);
                 if (strpos($taskInformation, Shunt::SIGNATURE_VAR) !== FALSE || strpos($taskInformation, Shunt::SIGNATURE_CLASS) !== FALSE || strpos($taskInformation, Shunt::SIGNATURE_NAMESPACE_CLASS) !== FALSE) {
                     $this->setTask($taskName, new ReflectionFunction($taskFunction));
                 }
             }
         }
     }
 }