class FeedsXPathParserQueryParserTestCase in Feeds XPath Parser 6
Same name and namespace in other branches
- 7 tests/feeds_xpathparser_query_parser.test \FeedsXPathParserQueryParserTestCase
@file Test cases for the xpath query parser.
Hierarchy
- class \DrupalTestCase
- class \DrupalUnitTestCase
Expanded class hierarchy of FeedsXPathParserQueryParserTestCase
File
- tests/
feeds_xpathparser_query_parser.test, line 7 - Test cases for the xpath query parser.
View source
class FeedsXPathParserQueryParserTestCase extends DrupalUnitTestCase {
/**
* Describe this test.
*/
public static function getInfo() {
return array(
'name' => t('Query Parser'),
'description' => t('Unit tests for the query parser inside Feeds XPath Parser.'),
'group' => t('Feeds XPath Parser'),
);
}
public function setUp() {
parent::setUp();
require_once dirname(__FILE__) . '/../FeedsXPathParserQueryParser.inc';
}
public function testSimple() {
$parser = new FeedsXPathParserQueryParser('cow');
$this
->assertEqual($parser
->getQuery(), '__default__:cow');
$parser = new FeedsXPathParserQueryParser('/cow');
$this
->assertEqual($parser
->getQuery(), '/__default__:cow');
$parser = new FeedsXPathParserQueryParser('/cow/barn');
$this
->assertEqual($parser
->getQuery(), '/__default__:cow/__default__:barn');
$parser = new FeedsXPathParserQueryParser('/cow/barn[@id = "asdfsaf"]');
$this
->assertEqual($parser
->getQuery(), '/__default__:cow/__default__:barn[@id = "asdfsaf"]');
$parser = new FeedsXPathParserQueryParser('/cow/barn[@id=chair]');
$this
->assertEqual($parser
->getQuery(), '/__default__:cow/__default__:barn[@id=__default__:chair]');
$parser = new FeedsXPathParserQueryParser('/cow:asdf');
$this
->assertEqual($parser
->getQuery(), '/cow:asdf');
$parser = new FeedsXPathParserQueryParser('@cow');
$this
->assertEqual($parser
->getQuery(), '@cow');
$parser = new FeedsXPathParserQueryParser('starts-with(@id, "cat")');
$this
->assertEqual($parser
->getQuery(), 'starts-with(@id, "cat")');
$parser = new FeedsXPathParserQueryParser('starts-with(cat/dog/fire:breather, "cat")');
$this
->assertEqual($parser
->getQuery(), 'starts-with(__default__:cat/__default__:dog/fire:breather, "cat")');
$parser = new FeedsXPathParserQueryParser('//state[@id = ../city[name="CityName"]/state_id]/name');
$this
->assertEqual($parser
->getQuery(), '//__default__:state[@id = ../__default__:city[__default__:name="CityName"]/__default__:state_id]/__default__:name');
$parser = new FeedsXPathParserQueryParser('attribute::lang');
$this
->assertEqual($parser
->getQuery(), 'attribute::lang');
$parser = new FeedsXPathParserQueryParser('child::book');
$this
->assertEqual($parser
->getQuery(), 'child::__default__:book');
$parser = new FeedsXPathParserQueryParser('child::*');
$this
->assertEqual($parser
->getQuery(), 'child::*');
$parser = new FeedsXPathParserQueryParser('child::text()');
$this
->assertEqual($parser
->getQuery(), 'child::text()');
$parser = new FeedsXPathParserQueryParser('ancestor-or-self::book');
$this
->assertEqual($parser
->getQuery(), 'ancestor-or-self::__default__:book');
$parser = new FeedsXPathParserQueryParser('child::*/child::price');
$this
->assertEqual($parser
->getQuery(), 'child::*/child::__default__:price');
$parser = new FeedsXPathParserQueryParser("/asdfasfd[@id = 'a' or @id='b']");
$this
->assertEqual($parser
->getQuery(), "/__default__:asdfasfd[@id = 'a' or @id='b']");
// Go! difficult xpath queries from stack overflow.
$parser = new FeedsXPathParserQueryParser("id('yui-gen2')/x:div[3]/x:div/x:a[1]");
$this
->assertEqual($parser
->getQuery(), "id('yui-gen2')/x:div[3]/x:div/x:a[1]");
$parser = new FeedsXPathParserQueryParser("/descendant::a[@class='buttonCheckout']");
$this
->assertEqual($parser
->getQuery(), "/descendant::__default__:a[@class='buttonCheckout']");
$parser = new FeedsXPathParserQueryParser("//a[@href='javascript:void(0)']");
$this
->assertEqual($parser
->getQuery(), "//__default__:a[@href='javascript:void(0)']");
$parser = new FeedsXPathParserQueryParser('//*/@attribute');
$this
->assertEqual($parser
->getQuery(), '//*/@attribute');
$parser = new FeedsXPathParserQueryParser('/descendant::*[attribute::attribute]');
$this
->assertEqual($parser
->getQuery(), '/descendant::*[attribute::attribute]');
$parser = new FeedsXPathParserQueryParser('//Event[not(System/Level = preceding::Level) or not(System/Task = preceding::Task)]');
$this
->assertEqual($parser
->getQuery(), '//__default__:Event[not(__default__:System/__default__:Level = preceding::__default__:Level) or not(__default__:System/__default__:Task = preceding::__default__:Task)]');
$parser = new FeedsXPathParserQueryParser("section[@type='cover']/line/@page");
$this
->assertEqual($parser
->getQuery(), "__default__:section[@type='cover']/__default__:line/@page");
$parser = new FeedsXPathParserQueryParser('/articles/article/*[name()="title" or name()="short"]');
$this
->assertEqual($parser
->getQuery(), '/__default__:articles/__default__:article/*[name()="title" or name()="short"]');
$parser = new FeedsXPathParserQueryParser("/*/article[@id='2']/*[self::title or self::short]");
$this
->assertEqual($parser
->getQuery(), "/*/__default__:article[@id='2']/*[self::__default__:title or self::__default__:short]");
$parser = new FeedsXPathParserQueryParser('not(/asdfasfd/asdfasf//asdfasdf) | /asdfasf/sadfasf/@asdf');
$this
->assertEqual($parser
->getQuery(), 'not(/__default__:asdfasfd/__default__:asdfasf//__default__:asdfasdf) | /__default__:asdfasf/__default__:sadfasf/@asdf');
$parser = new FeedsXPathParserQueryParser('Ülküdak');
$this
->assertEqual($parser
->getQuery(), '__default__:Ülküdak');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalTestCase:: |
protected | property | Assertions thrown in that test case. | |
DrupalTestCase:: |
protected | property | The database prefix of this test run. | |
DrupalTestCase:: |
protected | property | The original file directory, before it was changed for testing purposes. | |
DrupalTestCase:: |
protected | property | The original database prefix, before it was changed for testing purposes. | |
DrupalTestCase:: |
public | property | Current results of this test case. | |
DrupalTestCase:: |
protected | property | This class is skipped when looking for the source of an assertion. | |
DrupalTestCase:: |
protected | property | The test run ID. | |
DrupalTestCase:: |
protected | property | Time limit for the test. | |
DrupalTestCase:: |
protected | function | Internal helper: stores the assert. | |
DrupalTestCase:: |
protected | function | Check to see if two values are equal. | |
DrupalTestCase:: |
protected | function | Check to see if a value is false (an empty string, 0, NULL, or FALSE). | |
DrupalTestCase:: |
protected | function | Check to see if two values are identical. | |
DrupalTestCase:: |
protected | function | Check to see if two values are not equal. | |
DrupalTestCase:: |
protected | function | Check to see if two values are not identical. | |
DrupalTestCase:: |
protected | function | Check to see if a value is not NULL. | |
DrupalTestCase:: |
protected | function | Check to see if a value is NULL. | |
DrupalTestCase:: |
protected | function | Check to see if a value is not false (not an empty string, 0, NULL, or FALSE). | |
DrupalTestCase:: |
public static | function | Delete an assertion record by message ID. | |
DrupalTestCase:: |
protected | function | Fire an error assertion. | |
DrupalTestCase:: |
public | function | Handle errors during test runs. | |
DrupalTestCase:: |
protected | function | Handle exceptions. | |
DrupalTestCase:: |
protected | function | Fire an assertion that is always negative. | |
DrupalTestCase:: |
public static | function | Converts a list of possible parameters into a stack of permutations. | |
DrupalTestCase:: |
protected | function | Cycles through backtrace until the first non-assertion method is found. | |
DrupalTestCase:: |
public static | function | Store an assertion from outside the testing context. | |
DrupalTestCase:: |
protected | function | Fire an assertion that is always positive. | |
DrupalTestCase:: |
public static | function | Generates a random string containing letters and numbers. | |
DrupalTestCase:: |
public static | function | Generates a random string of ASCII characters of codes 32 to 126. | |
DrupalTestCase:: |
public | function | Run all tests in this class. | |
DrupalTestCase:: |
protected | function | Logs verbose message in a text file. | |
DrupalUnitTestCase:: |
protected | function | ||
DrupalUnitTestCase:: |
function |
Constructor for DrupalUnitTestCase. Overrides DrupalTestCase:: |
||
FeedsXPathParserQueryParserTestCase:: |
public static | function | Describe this test. | |
FeedsXPathParserQueryParserTestCase:: |
public | function |
Sets up unit test environment. Overrides DrupalUnitTestCase:: |
|
FeedsXPathParserQueryParserTestCase:: |
public | function |