Ejemplo n.º 1
0
 /**
  * Tests that set and get Items files return the same.
  */
 public function test_set_and_get_items_return_the_same()
 {
     $report = new Report\Report();
     $items = array('a' => 'b');
     $report->setItems($items);
     $this->assertEquals($items, $report->getItems());
 }
Ejemplo n.º 2
0
 /**
  * Return an instance of Report by providing an array to the method.
  *
  * @param array $array
  * @return Report
  */
 public static function fromArray($array = array())
 {
     $required = array('name', 'date', 'path', 'items');
     $report = new Report();
     /**
      * Check if all required fields are being set.
      */
     foreach ($required as $req) {
         if (isset($array[$req]) === false) {
             throw new Exception\RuntimeException('Could not create a report from this array field ' . $req . ' was not set the following fields are required (' . implode(',', $required) . ')');
         }
     }
     $report->setName($array['name']);
     $report->setDate($array['date']);
     $report->setPath($array['path']);
     $report->setItems($array['items']);
     return $report;
 }
Ejemplo n.º 3
0
 /**
  * Assert that writing to a local ftp server will fail if the user is not authenticated.
  */
 public function test_ftp_local_connection_file_write_fails()
 {
     if (($user = getenv('FTP_USER')) && ($pass = getenv('FTP_PASSWORD')) && ($host = getenv('FTP_HOST'))) {
         $ftp = new Adapter\Ftp('', '', '', 'httpdocs/scan_new.yml');
         $report = new Scan\Report\Report();
         $items = array('a' => 'b');
         $report->setItems($items);
         $result = $ftp->write($report);
         $this->assertFalse($result);
         unset($ftp);
     }
 }