Changeset 812 -- 2009-05-10 10:25:36
- Author
させざき
- Comment
- ちょこっとテスト追加
Diffs
HTML_ExtractContent/trunk/tests/HTML/ExtractContent/FromCpanTTest.php
@@ -3,7 +3,6 @@
require_once dirname(dirname(dirname(dirname(__FILE__)))).'/src/HTML/ExtractContent.php';
-$cpanDir = new DirectoryIterator(dirname(__FILE__).'/_files/cpan/');
/**
* Test class for HTML_ExtractContent.
@@ -17,6 +16,7 @@
*/
protected $object;
+ protected $cpanDir;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
@@ -26,6 +26,7 @@
protected function setUp()
{
$this->object = new HTML_ExtractContent;
+ $this->cpanDir = new DirectoryIterator(dirname(__FILE__).'/_files/cpan/');
}
/**
@@ -38,27 +39,13 @@
{
}
- /**
- * @todo Implement testAnalyze().
- */
- public function testAnalyze() {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ //01-util.t
+ public function testStripTags()
+ {
+
}
/**
- * @todo Implement testTitle().
- */
- public function testTitle() {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
* @todo Implement testSetOpt().
*/
public function testSetOpt() {
HTML_ExtractContent/trunk/tests/HTML/ExtractContent/ExtractContentTest.php
@@ -50,20 +50,33 @@
* @todo Implement testTitle().
*/
public function testTitle() {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+
+ $expect = 'TITLE01';
+ $html = <<<HTML
+<title id="test01">$expect</title>
+<title>TITLE02</title>
+HTML;
+
+// $this->
+ $this->assertEquals($expect,
+ $this->object->title($html));
}
/**
* @todo Implement testSetOpt().
*/
public function testSetOpt() {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+
+ $opt = $this->getObjectAttribute($this->object, 'opt');
+
+ $set = array('debug' => !$opt['debug']);
+ $this->object->setOpt($set);
+
+ $opt = $this->getObjectAttribute($this->object, 'opt');
+
+ $this->assertEquals($set['debug'], $opt['debug']);
+
}
}
+
?>
HTML_ExtractContent/trunk/src/HTML/ExtractContent.php
@@ -124,8 +124,12 @@
return $html;
}
-
-
+ /**
+ * extract title
+ *
+ * @param string
+ * @return string
+ */
public function title($html)
{
if (preg_match('/<title[^>]*>\s*(.*?)\s*<\/title\s*>/i', $html, $matches)) {