Skip to content
Permalink
Browse files

make ExtractTaskTest more robust

Asserting line numbers means that when the source changes the line
numbers need to change in the test cases. This is quite fragile causing
unrelated changes to cause this test case to fail. Converted to _not_
expect specific line numbers.
  • Loading branch information...
AD7six committed Nov 19, 2013
1 parent 880a15f commit a4a55a0b91c641436b41c2fb152e170e71f81e30
Showing with 9 additions and 10 deletions.
  1. +9 −10 Cake/Test/TestCase/Console/Command/Task/ExtractTaskTest.php
@@ -127,23 +127,23 @@ public function testExecute() {
$this->assertRegExp($pattern, $result);
// extract.ctp
$pattern = '/\#: (\\\\|\/)extract\.ctp:15;6\n';
$pattern = '/\#: (\\\\|\/)extract\.ctp:\d+;\d+\n';
$pattern .= 'msgid "You have %d new message."\nmsgid_plural "You have %d new messages."/';
$this->assertRegExp($pattern, $result);
$pattern = '/msgid "You have %d new message."\nmsgstr ""/';
$this->assertNotRegExp($pattern, $result, 'No duplicate msgid');
$pattern = '/\#: (\\\\|\/)extract\.ctp:7\n';
$pattern = '/\#: (\\\\|\/)extract\.ctp:\d+\n';
$pattern .= 'msgid "You deleted %d message."\nmsgid_plural "You deleted %d messages."/';
$this->assertRegExp($pattern, $result);
$pattern = '/\#: (\\\\|\/)extract\.ctp:14\n';
$pattern .= '\#: (\\\\|\/)home\.ctp:126\n';
$pattern = '/\#: (\\\\|\/)extract\.ctp:\d+\n';
$pattern .= '\#: (\\\\|\/)home\.ctp:\d+\n';
$pattern .= 'msgid "Editing this Page"\nmsgstr ""/';
$this->assertRegExp($pattern, $result);
$pattern = '/\#: (\\\\|\/)extract\.ctp:22\nmsgid "';
$pattern = '/\#: (\\\\|\/)extract\.ctp:\d+\nmsgid "';
$pattern .= 'Hot features!';
$pattern .= '\\\n - No Configuration: Set-up the database and let the magic begin';
$pattern .= '\\\n - Extremely Simple: Just look at the name...It\'s Cake';
@@ -190,8 +190,7 @@ public function testExtractCategory() {
$result = file_get_contents($this->path . DS . 'default.pot');
$pattern = '/\#: .*extract\.ctp:31\n/';
$this->assertNotRegExp($pattern, $result);
$this->assertNotContains('You have a new message (category: LC_TIME).', $result);
}
/**
@@ -214,10 +213,10 @@ public function testExtractWithExclude() {
$this->assertTrue(file_exists($this->path . DS . 'default.pot'));
$result = file_get_contents($this->path . DS . 'default.pot');
$pattern = '/\#: .*extract\.ctp:6\n/';
$pattern = '/\#: .*extract\.ctp:\d+\n/';
$this->assertNotRegExp($pattern, $result);
$pattern = '/\#: .*default\.ctp:26\n/';
$pattern = '/\#: .*default\.ctp:\d+\n/';
$this->assertNotRegExp($pattern, $result);
}
@@ -292,7 +291,7 @@ public function testExtractPlugin() {
$this->Task->execute();
$result = file_get_contents($this->path . DS . 'default.pot');
$this->assertNotRegExp('#Pages#', $result);
$this->assertContains('translate.ctp:1', $result);
$this->assertRegExp('/translate\.ctp:\d+/', $result);
$this->assertContains('This is a translatable string', $result);
$this->assertContains('I can haz plugin model validation message', $result);
}

0 comments on commit a4a55a0

Please sign in to comment.
You can’t perform that action at this time.