Browse Source

Improve parsehtml test

tags/0.6
Chris Smith 14 years ago
parent
commit
5066130f7d
2 changed files with 17 additions and 13 deletions
  1. 1
    0
      test/index.php
  2. 16
    13
      test/parsehtml.test.php

+ 1
- 0
test/index.php View File

5
    td, th { border: 1px solid #000; padding: 10px; }
5
    td, th { border: 1px solid #000; padding: 10px; }
6
    td.error { text-align: center; color: #fff; background-color: #c00; }
6
    td.error { text-align: center; color: #fff; background-color: #c00; }
7
    td.succ { text-align: center; color: #fff; background-color: #0c0; }
7
    td.succ { text-align: center; color: #fff; background-color: #0c0; }
8
+   var { font-size: small; color: purple; font-style: normal; padding: 0 2px; }
8
   </style>
9
   </style>
9
  </head>
10
  </head>
10
  <body>
11
  <body>

+ 16
- 13
test/parsehtml.test.php View File

6
    td, th { border: 1px solid #000; padding: 10px; }
6
    td, th { border: 1px solid #000; padding: 10px; }
7
    td.error { text-align: center; color: #fff; background-color: #c00; }
7
    td.error { text-align: center; color: #fff; background-color: #c00; }
8
    td.succ { text-align: center; color: #fff; background-color: #0c0; }
8
    td.succ { text-align: center; color: #fff; background-color: #0c0; }
9
+   var { font-size: small; color: purple; font-style: normal; padding: 0 2px; }
9
   </style>
10
   </style>
10
  </head>
11
  </head>
11
  <body>
12
  <body>
17
 
18
 
18
  require_once('../discoverer.inc.php');
19
  require_once('../discoverer.inc.php');
19
 
20
 
21
+ define('BASE_URI', 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/');
22
+
20
  function doHtmlTest($output, $input) {
23
  function doHtmlTest($output, $input) {
21
 
24
 
22
-  $disc = new Discoverer(null);
23
-  $disc->parseHtml(file_get_contents($input));
24
-  $aoutput = $disc->getVersion() . ':' . $disc->getEndpointUrl() . ',' . $disc->getOpLocalId();
25
+  $disc = new Discoverer(BASE_URI . $input);
26
+  $aoutput = $disc->getVersion() . "\n" . $disc->getEndpointUrl() . "\n" . $disc->getUserSuppliedId() . "\n" . $disc->getClaimedId() . "\n" . $disc->getOpLocalId();
27
+  $aoutput = str_replace(BASE_URI, '%URL%', $aoutput);
25
   $result = $aoutput == $output;
28
   $result = $aoutput == $output;
26
 
29
 
27
   echo '<tr><td><a href="', htmlentities($input), '">', htmlentities($input), '</a></td>';
30
   echo '<tr><td><a href="', htmlentities($input), '">', htmlentities($input), '</a></td>';
28
-  echo '<td>', htmlentities($output), '</td>';
29
-  echo '<td>', htmlentities($aoutput), '</td>';
31
+  echo '<td>', str_replace('%URL%', '<var>%URL%</var>', nl2br(htmlentities($output))), '</td>';
32
+  echo '<td>', str_replace('%URL%', '<var>%URL%</var>', nl2br(htmlentities($aoutput))), '</td>';
30
   echo '<td class="', $result ? 'succ' : 'error', '">';
33
   echo '<td class="', $result ? 'succ' : 'error', '">';
31
   echo $result ? 'Passed' : 'Failed';
34
   echo $result ? 'Passed' : 'Failed';
32
   echo '</td>';
35
   echo '</td>';
34
  }
37
  }
35
 
38
 
36
  $tests = array(
39
  $tests = array(
37
-  'samplehtml/test1.html' => '1:http://server.com/path,http://delegate.com/',
38
-  'samplehtml/test2.html' => '1:http://server.com/path,http://delegate.com/',
39
-  'samplehtml/test3.html' => '1:http://server/path?foo&bar,',
40
-  'samplehtml/v2-test1.html' => '2:http://server.com/path,http://delegate.com/',
41
-  'samplehtml/v2-test2.html' => '2:http://server.com/path,',
42
-  'samplehtml/v2-test3.html' => '2:http://server.com/path,',
43
-  'samplehtml/v2-test4.html' => '1:http://server.com/path,http://delegate.com/',
44
-  'samplehtml/v2-test5.html' => '1:http://server.com/path,http://delegate.com/',
40
+  'samplehtml/test1.html' => "1\nhttp://server.com/path\n%URL%samplehtml/test1.html\n%URL%samplehtml/test1.html\nhttp://delegate.com/",
41
+  'samplehtml/test2.html' => "1\nhttp://server.com/path\n%URL%samplehtml/test2.html\n%URL%samplehtml/test2.html\nhttp://delegate.com/",
42
+  'samplehtml/test3.html' => "1\nhttp://server/path?foo&bar\n%URL%samplehtml/test3.html\n%URL%samplehtml/test3.html\n",
43
+  'samplehtml/v2-test1.html' => "2\nhttp://server.com/path\n%URL%samplehtml/v2-test1.html\n%URL%samplehtml/v2-test1.html\nhttp://delegate.com/",
44
+  'samplehtml/v2-test2.html' => "2\nhttp://server.com/path\n%URL%samplehtml/v2-test2.html\n%URL%samplehtml/v2-test2.html\n%URL%samplehtml/v2-test2.html",
45
+  'samplehtml/v2-test3.html' => "2\nhttp://server.com/path\n%URL%samplehtml/v2-test3.html\n%URL%samplehtml/v2-test3.html\n%URL%samplehtml/v2-test3.html",
46
+  'samplehtml/v2-test4.html' => "1\nhttp://server.com/path\n%URL%samplehtml/v2-test4.html\n%URL%samplehtml/v2-test4.html\nhttp://delegate.com/",
47
+  'samplehtml/v2-test5.html' => "1\nhttp://server.com/path\n%URL%samplehtml/v2-test5.html\n%URL%samplehtml/v2-test5.html\nhttp://delegate.com/",
45
  );
48
  );
46
 
49
 
47
  array_walk($tests, 'doHtmlTest');
50
  array_walk($tests, 'doHtmlTest');

Loading…
Cancel
Save