Пример #1
0
 /**
  * All urls should always be more
  */
 public function testGetAllPaths()
 {
     $unreachablePath = new UnreachablePath();
     $defaultPaths = $unreachablePath->getPaths();
     $allPaths = $unreachablePath->getPaths(true);
     $this->assertGreaterThan($defaultPaths, $allPaths);
     $this->assertContains($defaultPaths[0], $allPaths);
 }
Пример #2
0
 /**
  * Execute command
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $unreachablePath = new UnreachablePath();
     $unreachablePath->setRequest($this->request);
     $results = $unreachablePath->checkPaths();
     foreach ($results as &$result) {
         if ($result[2] === false) {
             $result[2] = '<error>Fail</error>';
         } elseif ($result[2] === true) {
             $result[2] = '<bg=green>Pass</bg=green>';
         }
     }
     $this->out('Unreachable Path Check', [['type' => 'table', 'data' => [['Path', 'Response Code', 'Status'], $results]]]);
 }
Пример #3
0
 /**
  * Execute command
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->writeHeader('Unreachable Path Check');
     $unreachablePath = new UnreachablePath();
     $unreachablePath->setRequest($this->request);
     $results = $unreachablePath->checkPaths($this->url);
     foreach ($results as &$result) {
         if ($result[2] === false) {
             $result[2] = '<error>Fail</error>';
         } elseif ($result[2] === true) {
             $result[2] = '<bg=green>Pass</bg=green>';
         }
     }
     $table = new Table($this->output);
     $table->setHeaders(array('Path', 'Response Code', 'Status'))->setRows($results)->render();
 }
Пример #4
0
 /**
  * Execute command
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $unreachablePath = new UnreachablePath();
     $unreachablePath->setRequest($this->request);
     $results = $unreachablePath->checkPaths($this->url);
     if ($input->getOption('json')) {
         $cleanOut = [];
         foreach ($results as $r) {
             $cleanOut[$r[0]] = ["http_status" => $r[1], "status" => $r[2] ? "Pass" : "Fail"];
         }
         $output->write(json_encode($cleanOut));
     } else {
         foreach ($results as &$result) {
             if ($result[2] === false) {
                 $result[2] = '<error>Fail</error>';
             } elseif ($result[2] === true) {
                 $result[2] = '<bg=green>Pass</bg=green>';
             }
         }
         $this->writeHeader('Unreachable Path Check');
         $table = new Table($this->output);
         $table->setHeaders(array('Path', 'Response Code', 'Status'))->setRows($results)->render();
     }
 }
Пример #5
0
 /**
  * Check for unreachable paths
  *
  * @return void
  */
 public function checkUnreachablepathsingle()
 {
     $unreachablePath = new UnreachablePath();
     $result = $unreachablePath->checkPath($this->url, $_GET['path']);
     if ($result[2] === true) {
         return;
     }
     if ($result[2] === false) {
         $result[0] = '<a target="_blank" href="' . $this->url . $result[0] . '">' . $result[0] . '</a>';
         $result[2] = '<span class="fail">Reachable</span>';
     } elseif (substr($result[1], 0, 1) == 3) {
         if (substr($result[2], 0, 4) == 'http') {
             $newUrl = $result[2];
         } else {
             $newUrl = $this->url . substr($result[2], 1);
         }
         $result[0] = '<a target="_blank" href="' . $newUrl . '">' . $result[0] . '</a>';
         $result[2] = '<a target="_blank" href="' . $newUrl . '">Redirect</a>';
     }
     $this->respond($result);
 }