PHP Classes

File: tests/ReportTest.php

Recommend this page to a friend!
  Classes of Johnny Mast  >  Redbox PHP Scandir Filter  >  tests/ReportTest.php  >  Download  
File: tests/ReportTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: Redbox PHP Scandir Filter
Scan files for new or modified files
Author: By
Last change: Last minute changes
Date: 6 years ago
Size: 1,887 bytes
 

Contents

Class file image Download
<?php
namespace Redbox\Scan\Tests;
use
Redbox\Scan\Exception;
use
Redbox\Scan\Adapter;
use
Redbox\Scan;

/**
 * This class will run tests against the Report class.
 *
 * @coversDefaultClass \Redbox\Scan\Report\Report
 * @package Redbox\Scan\Tests
 */
class ReportTest extends \PHPUnit_Framework_TestCase
{

   
/**
     * We need to validate that a RuntimeException if the input array for method
     * Report::fromArray() does not contain the required keys.
     *
     * @expectedException \Redbox\Scan\Exception\RuntimeException
     */
   
public function test_report_from_array_method_should_throw_exception_if_wrong_keys_are_missing()
    {
       
$array = array(
           
'some' => 'value',
        );
       
Scan\Report\Report::fromArray($array);
    }

   
/**
     * We need to validate that a RuntimeException if the input array for method
     * Report::fromArray() does not contain the required keys.
     */
   
public function test_report_from_array_returns_a_valid_report()
    {
       
$array = array(
           
'name' => 'Test scan',
           
'date' => date(DATE_RFC2822),
           
'path' => '/somepath',
           
'items' => array(),
        );
       
$report = Scan\Report\Report::fromArray($array);
       
$this->assertInstanceOf('Redbox\Scan\Report\Report', $report);
    }

   
/**
     * We need to test that toArray method on an instance of Redbox\Scan\Report\Report
     * returns a valid array.
     */
   
public function test_report_to_array_returns_a_valid_array()
    {
       
$input = array(
           
'name' => 'Test scan',
           
'date' => date(DATE_RFC2822),
           
'path' => '/somepath',
           
'items' => array(),
        );
       
$report = Scan\Report\Report::fromArray($input);
       
$output = $report->toArray();

       
$this->assertEquals(json_encode($input), json_encode($output));
    }
}

For more information send a message to info at phpclasses dot org.