forked from yiisoft/yii2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit test that checks changelog formatting [skip ci]
- Loading branch information
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
/** | ||
* @link http://www.yiiframework.com/ | ||
* @copyright Copyright (c) 2008 Yii Software LLC | ||
* @license http://www.yiiframework.com/license/ | ||
*/ | ||
|
||
namespace yiiunit\framework; | ||
|
||
use yiiunit\TestCase; | ||
|
||
/** | ||
* ChangeLogTest. | ||
* @group base | ||
*/ | ||
class ChangeLogTest extends TestCase | ||
{ | ||
public function changeProvider() | ||
{ | ||
|
||
$lines = explode("\n", file_get_contents(__DIR__ . '/../../framework/CHANGELOG.md')); | ||
|
||
// Don't check last 1500 lines, they are old and often don't obey the standard. | ||
$lastIndex = count($lines) - 1500; | ||
$result = []; | ||
foreach($lines as $i => $line) { | ||
if (strncmp('- ', $line, 2) === 0) { | ||
$result[] = [$line]; | ||
} | ||
|
||
if ($i > $lastIndex) { | ||
break; | ||
} | ||
} | ||
return $result; | ||
} | ||
|
||
/** | ||
* @dataProvider changeProvider | ||
*/ | ||
public function testContributorLine($line) | ||
{ | ||
/** | ||
* Each change line is tested for: | ||
* - Starts with "- " | ||
* - Has a type: Bug, Enh, Chg, New | ||
* - Has a number formatted like #12345 | ||
* - Description starts after ": " | ||
* - Description ends without a "." | ||
* - Line ends with contributor name between "(" and ")". | ||
*/ | ||
$this->assertRegExp('/- (Bug|Enh|Chg|New)( #\d+(, #\d+)*)?: .*[^.] \(.*\)$/', $line); | ||
} | ||
} |