Services_W3C_HTMLValidator
[ class tree: Services_W3C_HTMLValidator ] [ index: Services_W3C_HTMLValidator ] [ all elements ]

Source for file URIValidationTest.php

Documentation is available at URIValidationTest.php

  1. <?php
  2. /**
  3.  * This file tests the validation of the web accessible URIs.
  4.  */
  5.  
  6. require_once 'Services/W3C/HTMLValidator.php';
  7. require_once 'PHPUnit/Framework.php';
  8.  
  9. // Call Services_W3C_HTMLValidatorTest::main() if executed directly.
  10. if (!defined("PHPUnit_MAIN_METHOD")) {
  11.     define("PHPUnit_MAIN_METHOD""URIValidationTest::main");
  12. }
  13.  
  14. class URIValidationTest extends PHPUnit_Framework_TestCase
  15. {
  16.     public $uri 'http://www.unl.edu/';
  17.     
  18.     protected $validator;
  19.     
  20.     /**
  21.      * Runs the test methods of this class.
  22.      *
  23.      * @access public
  24.      * @static
  25.      * @return void 
  26.      */
  27.     public static function main()
  28.     {
  29.         include_once "PHPUnit/TextUI/TestRunner.php";
  30.  
  31.         $suite  = new PHPUnit_Framework_TestSuite("URIValidationTest");
  32.         $result = PHPUnit_TextUI_TestRunner::run($suite);
  33.     }
  34.     
  35.     
  36.     public function setUp()
  37.     {
  38.         $this->validator = new Services_W3C_HTMLValidator();
  39.     }
  40.     
  41.     public function testURI()
  42.     {
  43.         $r $this->validator->validate($this->uri);
  44.         $this->assertEquals(get_class($r)'Services_W3C_HTMLValidator_Response');
  45.         if (!$r->isValid()) {
  46.             $message $this->constructErrorMessage($r);
  47.         else {
  48.             $message $r->uri.' is Valid';
  49.         }
  50.         $this->assertTrue($r->isValid()$message);
  51.     }
  52.     
  53.     public function testFile()
  54.     {
  55.         $r $this->validator->validate($this->uri);
  56.         $this->assertEquals(get_class($r)'Services_W3C_HTMLValidator_Response');
  57.         if (!$r->isValid()) {
  58.             $message $this->constructErrorMessage($r);
  59.         else {
  60.             $message $r->uri.' is Valid';
  61.         }
  62.         $this->assertTrue($r->isValid()$message);
  63.     }
  64.     
  65.     protected function constructErrorMessage(&$r)
  66.     {
  67.         $message $r->uri.' is NOT VALID: '.count($r->errors).' Errors -'.PHP_EOL;
  68.         foreach ($r->errors as $error{
  69.             $message .= ' - '.$error->message.PHP_EOL;
  70.         }
  71.         return $message;
  72.     }
  73. }
  74.  
  75. // Call Services_W3C_HTMLValidatorTest::main() if file is executed directly.
  76. if (PHPUnit_MAIN_METHOD == "URIValidationTest::main"{
  77.     URIValidationTest::main();
  78. }
  79. ?>

Documentation generated on Mon, 11 Mar 2019 15:37:09 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.