Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add test cases for currently open bugs

Rework tests so that there are less classes and they will run properly with phpunit


git-svn-id: http://svn.php.net/repository/pear/packages/XML_Feed_Parser/trunk@254599 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
commit fedac81982ddfeaf6059da71b7e50b008323751a 1 parent b263869
James Stewart authored
View
229 tests/accessTypes.php
@@ -9,181 +9,158 @@
* get a null or false return rather than an error. This test begins
* to ensure consistency of our API.
*/
-class XML_Feed_Parser_AccessTypes1_TestCase extends XML_Feed_Parser_TestCase
+class accessTypes extends XML_Feed_Parser_TestCase
{
- function __construct($name)
+ function __construct()
{
- $this->PHPUnit_TestCase($name);
- $sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
- $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'atom10-example1.xml');
- $this->feed = new XML_Feed_Parser($this->file);
- $this->entry = $this->feed->getEntryByOffset(0);
- }
-
- function setUp() {
- }
-
- function tearDown() {
+ $this->sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
+ $this->files = array('atom10-example1.xml', 'grwifi-atom.xml', 'technorati.feed',
+ 'delicious.feed', 'rss2sample.xml', 'atom10-example2.xml', 'rss10-example1.xml',
+ 'rss10-example2.xml');
}
function test_feedAuthor() {
- $this->assertEquals($this->feed->author, $this->feed->author());
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertEquals($feed->author, $feed->author());
+ }
}
function test_feedIcon() {
- $this->assertEquals($this->feed->icon, $this->feed->icon());
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertEquals($feed->icon, $feed->icon());
+ }
}
function test_feedId() {
- $this->assertEquals($this->feed->id, $this->feed->id());
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertEquals($feed->id, $feed->id());
+ }
}
function test_feedRights() {
- $this->assertEquals($this->feed->rights, $this->feed->rights());
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertEquals($feed->rights, $feed->rights());
+ }
}
function test_feedTitle() {
- $this->assertEquals($this->feed->title, $this->feed->title());
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertEquals($feed->title, $feed->title());
+ }
}
function test_feedSubtitle() {
- $this->assertEquals($this->feed->subtitle, $this->feed->subtitle());
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertEquals($feed->subtitle, $feed->subtitle());
+ }
}
function test_feedUpdated() {
- $this->assertEquals($this->feed->updated, $this->feed->updated());
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertEquals($feed->updated, $feed->updated());
+ }
}
function test_feedLink() {
- $this->assertEquals($this->feed->link, $this->feed->link());
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertEquals($feed->link, $feed->link());
+ }
}
function test_entryAuthor() {
- $this->assertEquals($this->entry->author, $this->entry->author());
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertEquals($entry->author, $entry->author());
+ }
}
function test_entryId() {
- $this->assertEquals($this->entry->id, $this->entry->id());
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertEquals($entry->id, $entry->id());
+ }
}
function test_entryPublished() {
- $this->assertEquals($this->entry->published, $this->entry->published());
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertEquals($entry->published, $entry->published());
+ }
}
function testEntryTitle() {
- $this->assertEquals($this->entry->title, $this->entry->title());
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertEquals($entry->title, $entry->title());
+ }
}
function testEntryRights() {
- $this->assertEquals($this->entry->rights, $this->entry->rights());
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertEquals($entry->rights, $entry->rights());
+ }
}
function testEntrySummary() {
- $this->assertEquals($this->entry->summary, $this->entry->summary());
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertEquals($entry->summary, $entry->summary());
+ }
}
function testEntryContent() {
- $this->assertEquals($this->entry->content, $this->entry->content());
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertEquals($entry->content, $entry->content());
+ }
}
function testEntryLink() {
- $this->assertEquals($this->entry->link, $this->entry->link());
- }
-}
-
-class XML_Feed_Parser_AccessTypes2_TestCase extends XML_Feed_Parser_AccessTypes1_TestCase
-{
- function __construct($name)
- {
- $this->PHPUnit_TestCase($name);
- $sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
- $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'atom10-example2.xml');
- $this->feed = new XML_Feed_Parser($this->file);
- $this->entry = $this->feed->getEntryByOffset(0);
- }
-}
-
-class XML_Feed_Parser_AccessTypes3_TestCase extends XML_Feed_Parser_AccessTypes1_TestCase
-{
- function __construct($name)
- {
- $this->PHPUnit_TestCase($name);
- $sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
- $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'rss10-example1.xml');
- $this->feed = new XML_Feed_Parser($this->file);
- $this->entry = $this->feed->getEntryByOffset(0);
- }
-}
-
-class XML_Feed_Parser_AccessTypes4_TestCase extends XML_Feed_Parser_AccessTypes1_TestCase
-{
- function __construct($name)
- {
- $this->PHPUnit_TestCase($name);
- $sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
- $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'rss10-example2.xml');
- $this->feed = new XML_Feed_Parser($this->file);
- $this->entry = $this->feed->getEntryByOffset(0);
- }
-}
-
-class XML_Feed_Parser_AccessTypes5_TestCase extends XML_Feed_Parser_AccessTypes1_TestCase
-{
- function __construct($name)
- {
- $this->PHPUnit_TestCase($name);
- $sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
- $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'rss2sample.xml');
- $this->feed = new XML_Feed_Parser($this->file);
- $this->entry = $this->feed->getEntryByOffset(0);
- }
-}
-
-class XML_Feed_Parser_AccessTypes6_TestCase extends XML_Feed_Parser_AccessTypes1_TestCase
-{
- function __construct($name)
- {
- $this->PHPUnit_TestCase($name);
- $sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
- $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'delicious.feed');
- $this->feed = new XML_Feed_Parser($this->file);
- $this->entry = $this->feed->getEntryByOffset(0);
- }
-}
-
-class XML_Feed_Parser_AccessTypes7_TestCase extends XML_Feed_Parser_AccessTypes1_TestCase
-{
- function __construct($name)
- {
- $this->PHPUnit_TestCase($name);
- $sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
- $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'technorati.feed');
- $this->feed = new XML_Feed_Parser($this->file);
- $this->entry = $this->feed->getEntryByOffset(0);
- }
-}
-
-class XML_Feed_Parser_AccessTypes8_TestCase extends XML_Feed_Parser_AccessTypes1_TestCase
-{
- function __construct($name)
- {
- $this->PHPUnit_TestCase($name);
- $sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
- $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'grwifi-atom.xml');
- $this->feed = new XML_Feed_Parser($this->file);
- $this->entry = $this->feed->getEntryByOffset(0);
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertEquals($entry->link, $entry->link());
+ }
}
}
-
-$suite = new PHPUnit_TestSuite;
-$suite->addTestSuite('XML_Feed_Parser_AccessTypes1_TestCase');
-$suite->addTestSuite('XML_Feed_Parser_AccessTypes2_TestCase');
-$suite->addTestSuite('XML_Feed_Parser_AccessTypes3_TestCase');
-$suite->addTestSuite('XML_Feed_Parser_AccessTypes4_TestCase');
-$suite->addTestSuite('XML_Feed_Parser_AccessTypes5_TestCase');
-$suite->addTestSuite('XML_Feed_Parser_AccessTypes6_TestCase');
-$suite->addTestSuite('XML_Feed_Parser_AccessTypes7_TestCase');
-$suite->addTestSuite('XML_Feed_Parser_AccessTypes8_TestCase');
-$result = PHPUnit::run($suite, '123');
-echo $result->toString();
-?>
View
257 tests/atomCompliance.php
@@ -9,218 +9,181 @@
* get a null or false return rather than an error. This test begins
* to ensure consistency of our API.
*/
-class XML_Feed_Parser_AtomCompat1_TestCase extends XML_Feed_Parser_TestCase
+class atomCompliance extends XML_Feed_Parser_TestCase
{
- function __construct($name)
+ function setUp()
{
- $this->PHPUnit_TestCase($name);
- $sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
- $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'atom10-example1.xml');
- $this->parser = new XML_Feed_Parser($this->file);
- $this->entry = $this->parser->getEntryByOffset(0);
+ $this->sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
+ $this->files = array('atom10-example1.xml', 'atom10-example2.xml', 'rss10-example1.xml',
+ 'rss10-example2.xml', 'rss2sample.xml', 'delicious.feed', 'technorati.feed', 'grwifi-atom.xml');
}
- function setUp() {
- }
-
- function tearDown() {
- }
-
- function checkString($attribute, $entry = false) {
- if ($entry) {
- $author = $this->entry->$attribute;
- } else {
- $author = $this->parser->$attribute;
- }
- if (is_string($author) or $author === false) {
- $test = true;
- }
+ function checkString($attribute, $element) {
+ $item = $element->$attribute;
+ $test = (is_string($item) or $item === false);
return $test;
}
- function checkNumeric($attribute, $entry = false) {
- if ($entry) {
- $author = $this->entry->$attribute;
- } else {
- $author = $this->parser->$attribute;
- }
- if (is_numeric($author)) {
- $test = true;
- } else if ($author === false) {
- $test = true;
- }
+ function checkNumeric($attribute, $element) {
+ $item = $element->$attribute;
+ $test = (is_numeric($item) or $item === false);
return $test;
}
function test_feedAuthor() {
- $this->assertTrue($this->checkString('author'));
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $this->assertTrue($this->checkString('author', $feed), "Failed for $file");
+ }
}
function test_feedContributor()
{
- $this->assertTrue($this->checkString('contributor'));
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $this->assertTrue($this->checkString('contributor', $feed), "Failed for $file");
+ }
}
function test_feedIcon() {
- $this->assertTrue($this->checkString('icon'));
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $this->assertTrue($this->checkString('icon', $feed), "Failed for $file");
+ }
}
function test_feedId() {
- $this->assertTrue($this->checkString('id'));
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $this->assertTrue($this->checkString('id', $feed), "Failed for $file");
+ }
}
function test_feedRights() {
- $this->assertTrue($this->checkString('rights'));
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $this->assertTrue($this->checkString('rights', $feed), "Failed for $file");
+ }
}
function test_feedTitle() {
- $this->assertTrue($this->checkString('title'));
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $this->assertTrue($this->checkString('title', $feed), "Failed for $file");
+ }
}
function test_feedSubtitle() {
- $this->assertTrue($this->checkString('subtitle'));
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $this->assertTrue($this->checkString('subtitle', $feed), "Failed for $file");
+ }
}
function test_feedUpdated() {
- $this->assertTrue($this->checkNumeric('updated'));
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $this->assertTrue($this->checkNumeric('updated', $feed), "Failed for $file");
+ }
}
function test_feedLink() {
- $this->assertTrue($this->checkString('link'));
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $this->assertTrue($this->checkString('link', $feed), "Failed for $file");
+ }
}
function test_entryAuthor() {
- $this->assertTrue($this->checkString('author', true));
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertTrue($this->checkString('author', $entry), "Failed for $file");
+ }
}
function test_entryContributor()
{
- $this->assertTrue($this->checkString('contributor', true));
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertTrue($this->checkString('contributor', $entry), "Failed for $file");
+ }
}
function test_entryId() {
- $this->assertTrue($this->checkString('id', true));
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertTrue($this->checkString('id', $entry), "Failed for $file");
+ }
}
function test_entryPublished() {
- $this->assertTrue($this->checkNumeric('published', true));
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertTrue($this->checkNumeric('published', $entry), "Failed for $file");
+ }
}
function testEntryTitle() {
- $this->assertTrue($this->checkString('title', true));
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertTrue($this->checkString('title', $entry), "Failed for $file");
+ }
}
function testEntryRights() {
- $this->assertTrue($this->checkString('rights', true));
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertTrue($this->checkString('rights', $entry), "Failed for $file");
+ }
}
function testEntrySummary() {
- $this->assertTrue($this->checkString('summary', true));
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertTrue($this->checkString('summary', $entry), "Failed for $file");
+ }
}
function testEntryContent() {
- $this->assertTrue($this->checkString('content', true));
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertTrue($this->checkString('content', $entry), "Failed for $file");
+ }
}
function testEntryLink() {
- $this->assertTrue($this->checkString('link', true));
- }
-}
-
-class XML_Feed_Parser_AtomCompat2_TestCase extends XML_Feed_Parser_AtomCompat1_TestCase
-{
- function __construct($name)
- {
- $this->PHPUnit_TestCase($name);
- $sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
- $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'atom10-example2.xml');
- $this->parser = new XML_Feed_Parser($this->file);
- $this->entry = $this->parser->getEntryByOffset(0);
- }
-}
-
-class XML_Feed_Parser_AtomCompat3_TestCase extends XML_Feed_Parser_AtomCompat1_TestCase
-{
- function __construct($name)
- {
- $this->PHPUnit_TestCase($name);
- $sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
- $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'rss10-example1.xml');
- $this->parser = new XML_Feed_Parser($this->file);
- $this->entry = $this->parser->getEntryByOffset(0);
- }
-}
-
-class XML_Feed_Parser_AtomCompat4_TestCase extends XML_Feed_Parser_AtomCompat1_TestCase
-{
- function __construct($name)
- {
- $this->PHPUnit_TestCase($name);
- $sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
- $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'rss10-example2.xml');
- $this->parser = new XML_Feed_Parser($this->file);
- $this->entry = $this->parser->getEntryByOffset(0);
- }
-}
-
-class XML_Feed_Parser_AtomCompat5_TestCase extends XML_Feed_Parser_AtomCompat1_TestCase
-{
- function __construct($name)
- {
- $this->PHPUnit_TestCase($name);
- $sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
- $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'rss2sample.xml');
- $this->parser = new XML_Feed_Parser($this->file);
- $this->entry = $this->parser->getEntryByOffset(0);
- }
-}
-
-class XML_Feed_Parser_AtomCompat6_TestCase extends XML_Feed_Parser_AtomCompat1_TestCase
-{
- function __construct($name)
- {
- $this->PHPUnit_TestCase($name);
- $sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
- $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'delicious.feed');
- $this->parser = new XML_Feed_Parser($this->file);
- $this->entry = $this->parser->getEntryByOffset(0);
- }
-}
-
-class XML_Feed_Parser_AtomCompat7_TestCase extends XML_Feed_Parser_AtomCompat1_TestCase
-{
- function __construct($name)
- {
- $this->PHPUnit_TestCase($name);
- $sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
- $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'technorati.feed');
- $this->parser = new XML_Feed_Parser($this->file);
- $this->entry = $this->parser->getEntryByOffset(0);
- }
-}
-
-class XML_Feed_Parser_AtomCompat8_TestCase extends XML_Feed_Parser_AtomCompat1_TestCase
-{
- function __construct($name)
- {
- $this->PHPUnit_TestCase($name);
- $sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
- $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'grwifi-atom.xml');
- $this->parser = new XML_Feed_Parser($this->file);
- $this->entry = $this->parser->getEntryByOffset(0);
+ foreach ($this->files as $file) {
+ $contents = file_get_contents($this->sample_dir . DIRECTORY_SEPARATOR . $file);
+ $feed = new XML_Feed_Parser($contents);
+ $entry = $feed->getEntryByOffset(0);
+ $this->assertTrue($this->checkString('link', $entry), "Failed for $file");
+ }
}
}
-$suite = new PHPUnit_TestSuite;
-$suite->addTestSuite('XML_Feed_Parser_AtomCompat1_TestCase');
-$suite->addTestSuite('XML_Feed_Parser_AtomCompat2_TestCase');
-$suite->addTestSuite('XML_Feed_Parser_AtomCompat3_TestCase');
-$suite->addTestSuite('XML_Feed_Parser_AtomCompat4_TestCase');
-$suite->addTestSuite('XML_Feed_Parser_AtomCompat5_TestCase');
-$suite->addTestSuite('XML_Feed_Parser_AtomCompat6_TestCase');
-$suite->addTestSuite('XML_Feed_Parser_AtomCompat7_TestCase');
-$suite->addTestSuite('XML_Feed_Parser_AtomCompat8_TestCase');
-$result = PHPUnit::run($suite, '123');
-echo $result->toString();
-?>
View
14 tests/atomEntryOnly.php
@@ -2,13 +2,13 @@
require_once 'XML_Feed_Parser_TestCase.php';
-class XML_Feed_Parser_AtomEntryOnly_TestCase extends XML_Feed_Parser_TestCase
+class atomEntryOnly extends XML_Feed_Parser_TestCase
{
- function __construct($name)
+ function setUp()
{
- $this->PHPUnit_TestCase($name);
$sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
- $this->feed = new XML_Feed_Parser(file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'atom10-entryonly.xml'));
+ $xml = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'atom10-entryonly.xml');
+ $this->feed = new XML_Feed_Parser($xml);
$this->entry = $this->feed->getEntryByOffset(0);
}
@@ -85,9 +85,3 @@ function test_entryXPath()
}
}
-$suite = new PHPUnit_TestSuite;
-$suite->addTestSuite('XML_Feed_Parser_AtomEntryOnly_TestCase');
-$result = PHPUnit::run($suite, '123');
-echo $result->toString();
-
-?>
View
9 tests/atomValues.php
@@ -2,11 +2,10 @@
require_once 'XML_Feed_Parser_TestCase.php';
-class XML_Feed_Parser_Atom_valueValidity_TestCase extends XML_Feed_Parser_TestCase
+class atomValues extends XML_Feed_Parser_TestCase
{
- function __construct($name)
+ function setUp()
{
- $this->PHPUnit_TestCase($name);
$sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
$this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'atom10-example2.xml');
$this->feed = new XML_Feed_Parser($this->file);
@@ -167,8 +166,4 @@ function test_htmlUnencoding() {
}
}
-$suite = new PHPUnit_TestSuite('XML_Feed_Parser_Atom_valueValidity_TestCase');
-$result = PHPUnit::run($suite, '123');
-echo $result->toString();
-
?>
View
19 tests/errors.php
@@ -7,20 +7,8 @@
* particular we check that it throws an exception if we hand in an
* illegal feed type.
*/
-class XML_Feed_Parser_ThrowErrors_TestCase extends XML_Feed_Parser_TestCase
+class errors extends XML_Feed_Parser_TestCase
{
-
- function __construct($name)
- {
- $this->PHPUnit_TestCase($name);
- }
-
- function setUp() {
- }
-
- function tearDown() {
- }
-
function test_fakeFeedType()
{
$file = "<myfeed><myitem /></myfeed>";
@@ -90,9 +78,4 @@ function test_missingElement() {
}
}
-$suite = new PHPUnit_TestSuite;
-$suite->addTestSuite("XML_Feed_Parser_ThrowErrors_TestCase");
-$result = PHPUnit::run($suite, "123");
-echo $result->toString();
-
?>
View
8 tests/farsi.php
@@ -2,11 +2,10 @@
require_once 'XML_Feed_Parser_TestCase.php';
-class XML_Feed_Parser_Farsi_TestCase extends XML_Feed_Parser_TestCase
+class farsi extends XML_Feed_Parser_TestCase
{
- function __construct($name)
+ function setUp()
{
- $this->PHPUnit_TestCase($name);
$sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
$this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'hoder.xml');
$this->feed = new XML_Feed_Parser($this->file);
@@ -20,8 +19,5 @@ function test_itemTitleFarsi()
}
}
-$suite = new PHPUnit_TestSuite('XML_Feed_Parser_Farsi_TestCase');
-$result = PHPUnit::run($suite, '123');
-echo $result->toString();
?>
View
13 tests/iteration.php
@@ -2,17 +2,13 @@
require_once 'XML_Feed_Parser_TestCase.php';
-class XML_Feed_Parser_Iteration_TestCase extends XML_Feed_Parser_TestCase
+class iteration extends XML_Feed_Parser_TestCase
{
- function __construct($name)
+ function setUp()
{
- $this->PHPUnit_TestCase($name);
$this->sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
}
- function setUp() {
- }
-
function tearDown() {
}
@@ -45,9 +41,4 @@ function test_RSS2() {
}
}
-$suite = new PHPUnit_TestSuite;
-$suite->addTestSuite("XML_Feed_Parser_Iteration_TestCase");
-$result = PHPUnit::run($suite, "123");
-echo $result->toString();
-
?>
View
9 tests/japanese.php
@@ -2,11 +2,10 @@
require_once 'XML_Feed_Parser_TestCase.php';
-class XML_Feed_Parser_Japanese_TestCase extends XML_Feed_Parser_TestCase
+class japanese extends XML_Feed_Parser_TestCase
{
- function __construct($name)
+ function setUp()
{
- $this->PHPUnit_TestCase($name);
$sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
$this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . "sixapart-jp.xml");
$this->feed = new XML_Feed_Parser($this->file);
@@ -37,8 +36,4 @@ function test_itemDescriptionJapanese()
}
}
-$suite = new PHPUnit_TestSuite("XML_Feed_Parser_Japanese_TestCase");
-$result = PHPUnit::run($suite, "123");
-echo $result->toString();
-
?>
View
69 tests/regressions.php
@@ -0,0 +1,69 @@
+<?php
+
+require_once 'XML_Feed_Parser_TestCase.php';
+
+/**
+ * This is a set of tests for specific reported bugs.
+ */
+class Regressions extends XML_Feed_Parser_TestCase
+{
+ function setUp()
+ {
+ $this->sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
+ }
+
+ /**
+ * Issue 13215 reported some problems with HTML entity parsing not supporting
+ * the correct content types
+ *
+ * @url http://pear.php.net/bugs/bug.php?id=13215
+ */
+ function test_entitiesSupportForIssue13215()
+ {
+ $xml = file_get_contents($this->sample_dir . "/bug13215.xml");
+ $feed = new XML_Feed_Parser($xml);
+ $entry = $feed->getEntryById('http://www.thepost.ohiou.edu/Articles/News/2008/03/07/23319/');
+ $this->assertRegexp('/&ldquo;We&rsquo;re ready to take it to the courts/', $entry->content);
+ }
+
+ /**
+ * Some feeds may have more than one <enclosure> element defined to
+ * associate multiple files with a single field (eg., for the same video in
+ * multiple formats). XML_Feed_Parser seems to only support a single
+ * <enclosure> element. If more than one element is included in the feed,
+ * only the last one will be accessible through $item->enclosure.
+ *
+ * @todo Get sample of feed to use in this test
+ * @url http://pear.php.net/bugs/bug.php?id=12844
+ **/
+ // function test_handlesMultipleEnclosures()
+ // {
+ // $xml = file_get_contents($this->sample_dir . "/bug12844.xml");
+ // $feed = new XML_Feed_Parser($xml);
+ // }
+
+
+ /**
+ * German umlauts (ÄÖÜäöüß) from an atom xml file (encoding="iso-8859-1")
+ * are displayed wrong after parsing, eg. http://www.keine-gentechnik.de/news-regionen.xml
+ *
+ * @url http://pear.php.net/bugs/bug.php?id=12916
+ **/
+ function test_handlesGermanUmlauts()
+ {
+ $xml = file_get_contents($this->sample_dir . "/bug12916.xml");
+ $feed = new XML_Feed_Parser($xml);
+ $entry = $feed->getEntryById('sample-feed:1');
+ $this->assertEquals('ÄÜÖäüöß', $entry->title);
+ $this->assertEquals('&Auml;&Uuml;&Ouml;&auml;&uuml;&ouml;&szlig;', $entry->content);
+ }
+
+ function test_handlesAmpersandsInUrls()
+ {
+ $xml = file_get_contents($this->sample_dir . "/bug12919.xml");
+ $feed = new XML_Feed_Parser($xml);
+ $entry = $feed->getEntryById('entry-id');
+ $this->assertEquals('<a href="http://www.vzbv.de/start/index.php?page=presse&amp;bereichs_id=25">Linktext</a>',
+ trim($entry->content));
+ }
+}
View
10 tests/rss091Values.php
@@ -2,11 +2,10 @@
require_once 'XML_Feed_Parser_TestCase.php';
-class XML_Feed_Parser_RSS091_valueValidity_TestCase extends XML_Feed_Parser_TestCase
+class rss091Values extends XML_Feed_Parser_TestCase
{
- function __construct($name)
+ function setUp()
{
- $this->PHPUnit_TestCase($name);
$sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
$this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . "rss091-complete.xml");
$this->feed = new XML_Feed_Parser($this->file, false, true);
@@ -141,9 +140,4 @@ function test_entryDescription()
}
}
-$suite = new PHPUnit_TestSuite;
-$suite->addTestSuite("XML_Feed_Parser_RSS091_valueValidity_TestCase");
-$result = PHPUnit::run($suite, "123");
-echo $result->toString();
-
?>
View
10 tests/rss092Values.php
@@ -2,11 +2,10 @@
require_once 'XML_Feed_Parser_TestCase.php';
-class XML_Feed_Parser_RSS092_valueValidity_TestCase extends XML_Feed_Parser_TestCase
+class rss092Values extends XML_Feed_Parser_TestCase
{
- function __construct($name)
+ function setUp()
{
- $this->PHPUnit_TestCase($name);
$sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
$this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . "rss092-sample.xml");
$this->feed = new XML_Feed_Parser($this->file, false, true);
@@ -95,9 +94,4 @@ function test_entryEnclosure()
}
}
-$suite = new PHPUnit_TestSuite;
-$suite->addTestSuite("XML_Feed_Parser_RSS092_valueValidity_TestCase");
-$result = PHPUnit::run($suite, "123");
-echo $result->toString();
-
?>
View
14 tests/rss1Values.php
@@ -2,21 +2,16 @@
require_once 'XML_Feed_Parser_TestCase.php';
-class XML_Feed_Parser_RSS1_valueValidity_TestCase extends XML_Feed_Parser_TestCase
+class rss1Values extends XML_Feed_Parser_TestCase
{
- function __construct($name)
+ function setUp()
{
- $this->PHPUnit_TestCase($name);
$sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
$this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . "rss10-example2.xml");
$this->feed = new XML_Feed_Parser($this->file);
$this->entry = $this->feed->getEntryByOffset(0);
}
- function setup()
- {
- }
-
function test_feedNumberItems()
{
$value = 1;
@@ -181,9 +176,4 @@ function test_feedTextInput()
}
}
-$suite = new PHPUnit_TestSuite;
-$suite->addTestSuite("XML_Feed_Parser_RSS1_valueValidity_TestCase");
-$result = PHPUnit::run($suite, "123");
-echo $result->toString();
-
?>
View
77 tests/rss2Values.php
@@ -2,22 +2,23 @@
require_once 'XML_Feed_Parser_TestCase.php';
-class XML_Feed_Parser_RSS2_valueValidity_TestCase extends XML_Feed_Parser_TestCase
+class rss2Values extends XML_Feed_Parser_TestCase
{
- function __construct($name)
+
+ protected function setUp()
{
- $this->PHPUnit_TestCase($name);
- $sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
- $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . "rss2sample.xml");
- $this->feed = new XML_Feed_Parser($this->file);
- $this->entry = $this->feed->getEntryByOffset(2);
+ $sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
+ $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . "rss2sample.xml");
+ $this->feed = new XML_Feed_Parser($this->file);
+ $this->entry = $this->feed->getEntryByOffset(2);
}
-
+
function test_feedNumberItems()
{
$value = 4;
$this->assertEquals($value, $this->feed->numberEntries);
}
+
function test_feedTitle()
{
$value = "Liftoff News";
@@ -132,16 +133,56 @@ function test_entryIdEquivalence()
$this->assertEquals($value, $this->entry->id);
}
- function test_entryContent()
- {
- $value = "<p>Test content</p>";
- $this->assertEquals($value, $this->entry->content);
- }
+ function test_entryContent()
+ {
+ $value = "<p>Test content</p>";
+ $this->assertEquals($value, $this->entry->content);
+ }
+
+ function test_imageNodeInDifferentNamespaces()
+ {
+ $value = '<?xml version="1.0" encoding="utf-8"?>
+ <rss version="2.0"
+ xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
+ <channel>
+ <title>Tobbis-Podcast</title>
+ <itunes:image href="http://www.herbertschuette.de/Bilder/logo5.jpg" />
+ <image>
+ <url>http://www.herbertschuette.de/Bilder/logo5.jpg</url>
+ <title>Tobbis-Podcast</title>
+ <link>http://www.tobbis-podcast.de/</link>
+ </image>
+ </channel>
+ </rss>';
+ $parsed = new XML_Feed_Parser($value);
+ $this->assertEquals("http://www.herbertschuette.de/Bilder/logo5.jpg", $parsed->image['url']);
+ }
+
+ // function test_imageNodeAtDifferentLevels()
+ // {
+ // $sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
+ // $value = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . "rss2sample.xml");
+ // $parsed = new XML_Feed_Parser($value);
+ // $this->assertEquals(false, $parsed->image);
+ // }
+
+ function test_handlesEmptyPubdates()
+ {
+ $value = '<?xml version="1.0" encoding="utf-8"?>
+ <rss version="2.0"
+ xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
+ <channel>
+ <title>Tobbis-Podcast</title>
+ <item>
+ <title>Entry</title>
+ </item>
+ </channel>
+ </rss>';
+ $parsed = new XML_Feed_Parser($value);
+ $this->assertEquals(false, $parsed->pubDate);
+ $entry = $parsed->entries(0);
+ $this->assertEquals(false, $entry['pubDate']);
+ }
}
-$suite = new PHPUnit_TestSuite;
-$suite->addTestSuite("XML_Feed_Parser_RSS2_valueValidity_TestCase");
-$result = PHPUnit::run($suite, "123");
-echo $result->toString();
-
?>
View
19 tests/tidy.php
@@ -2,20 +2,8 @@
require_once 'XML_Feed_Parser_TestCase.php';
-class XML_Feed_Parser_Tidy_TestCase extends XML_Feed_Parser_TestCase
+class tidy extends XML_Feed_Parser_TestCase
{
-
- function __construct($name)
- {
- $this->PHPUnit_TestCase($name);
- }
-
- function setUp() {
- }
-
- function tearDown() {
- }
-
/**
* Try to work with this ill-formed feed. If the tidy extension is not installed,
* it expects parsing to fail. If tidy is installed and parsing fails, the test
@@ -39,9 +27,4 @@ function test_Tidy() {
}
}
-$suite = new PHPUnit_TestSuite;
-$suite->addTestSuite("XML_Feed_Parser_Tidy_TestCase");
-$result = PHPUnit::run($suite, "123");
-echo $result->toString();
-
?>
View
19 tests/xmlbase.php
@@ -2,20 +2,8 @@
require_once 'XML_Feed_Parser_TestCase.php';
-class XML_Feed_Parser_XMLBase_TestCase extends XML_Feed_Parser_TestCase
+class xmlbase extends XML_Feed_Parser_TestCase
{
-
- function __construct($name)
- {
- $this->PHPUnit_TestCase($name);
- }
-
- function setUp() {
- }
-
- function tearDown() {
- }
-
function test_Base() {
$sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
$file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . "xmlbase.xml");
@@ -29,9 +17,4 @@ function test_Base() {
}
}
-$suite = new PHPUnit_TestSuite;
-$suite->addTestSuite("XML_Feed_Parser_XMLBase_TestCase");
-$result = PHPUnit::run($suite, "123");
-echo $result->toString();
-
?>
Please sign in to comment.
Something went wrong with that request. Please try again.