parser.test in Patterns 7
Same filename and directory in other branches
SimpleTests for the Taxonomy component of Patterns.
File
tests/parser/parser.testView source
<?php
/**
* @file
* SimpleTests for the Taxonomy component of Patterns.
*/
class PatternsParserTestCase extends PatternsTestCase {
var $parser_tests_dir;
public static function getInfo() {
return array(
'name' => 'Parser',
'description' => 'Tests the validation algorithm against valid and invalid patterns.',
'group' => 'Patterns',
);
}
public function setUp($modules = array(), $first = FALSE) {
$this->parser_tests_dir = $this
->getPatternsTestDir() . 'parser/';
// Enable any modules required for the tests.
$modules = array(
'patterns_components',
'patterns_yamlparser',
);
parent::setUp($modules);
}
public function testValidP() {
$dir = $this->parser_tests_dir . 'valid/';
$this
->callbackOnDir($dir, array(
&$this,
'check_valid',
));
}
public function testInvalidP() {
$dir = $this->parser_tests_dir . 'invalid/';
$this
->callbackOnDir($dir, array(
&$this,
'check_invalid',
));
}
private function basic_checks($pattern) {
$scan = patterns_scan_pattern($pattern);
$this
->assertNotNull($scan, t('Pattern file loaded and scanned.'));
$analysis = _patterns_scan_analyze_patternscan($scan);
$this
->assertNotNull($analysis, t('Pattern-scan was analyzed successfully.'));
return $analysis;
}
public function check_valid($pattern) {
$analysis = $this
->basic_checks($pattern);
$this
->assertEqual(count($analysis), 0, t('No error message generated while parsing valid pattern.'));
}
public function check_invalid($pattern) {
$analysis = $this
->basic_checks($pattern);
$this
->assertNotEqual(count($analysis), 0, t('Error messages generated while parsing invalid pattern.'));
}
}
Classes
Name | Description |
---|---|
PatternsParserTestCase | @file SimpleTests for the Taxonomy component of Patterns. |