mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Additional test cases and fixes for Version Yaml parser
This commit is contained in:
parent
05b941e72b
commit
9a800ad656
@ -22,7 +22,7 @@ class VersionYamlProcessor extends YamlProcessor
|
||||
|
||||
foreach ($lines as $num => &$line) {
|
||||
// Surround array keys with quotes if not already
|
||||
$line = preg_replace_callback('/^\s*([\'"]{0}[^\'"\n\r:]+[\'"]{0})\s*:/m', function ($matches) {
|
||||
$line = preg_replace_callback('/^\s*([\'"]{0}[^\'"\n\r\-:]+[\'"]{0})\s*:/m', function ($matches) {
|
||||
return '"' . trim($matches[1]) . '":';
|
||||
}, rtrim($line));
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
"1.5.1":
|
||||
- Improved signature with the Test::method()
|
||||
- Translation updates.
|
||||
"1.5.0": "!!! Another major update to fix several issues"
|
||||
"1.4.1": !!! Major update here.
|
||||
1.3.2:
|
||||
Added support for Translate plugin.
|
||||
|
@ -24,7 +24,7 @@ class VersionManagerTest extends TestCase
|
||||
$result = self::callProtectedMethod($manager, 'getLatestFileVersion', ['\Winter\\Tester']);
|
||||
|
||||
$this->assertNotNull($result);
|
||||
$this->assertEquals('1.4.1', $result);
|
||||
$this->assertEquals('1.5.1', $result);
|
||||
}
|
||||
|
||||
public function testGetFileVersions()
|
||||
@ -32,7 +32,7 @@ class VersionManagerTest extends TestCase
|
||||
$manager = VersionManager::instance();
|
||||
$result = self::callProtectedMethod($manager, 'getFileVersions', ['\Winter\\Tester']);
|
||||
|
||||
$this->assertCount(11, $result);
|
||||
$this->assertCount(13, $result);
|
||||
$this->assertArrayHasKey('1.0.1', $result);
|
||||
$this->assertArrayHasKey('1.0.2', $result);
|
||||
$this->assertArrayHasKey('1.0.3', $result);
|
||||
@ -44,6 +44,8 @@ class VersionManagerTest extends TestCase
|
||||
$this->assertArrayHasKey('1.3.1', $result);
|
||||
$this->assertArrayHasKey('1.3.2', $result);
|
||||
$this->assertArrayHasKey('1.4.1', $result);
|
||||
$this->assertArrayHasKey('1.5.0', $result);
|
||||
$this->assertArrayHasKey('1.5.1', $result);
|
||||
|
||||
$sample = $result['1.0.1'];
|
||||
$this->assertEquals('Added some upgrade file and some "seeding"', $sample[0]);
|
||||
@ -65,6 +67,13 @@ class VersionManagerTest extends TestCase
|
||||
$sample = $result['1.3.2'];
|
||||
$this->assertEquals('Added support for Translate plugin. Added some new languages.', $sample);
|
||||
|
||||
$sample = $result['1.5.0'];
|
||||
$this->assertEquals('!!! Another major update to fix several issues', $sample);
|
||||
|
||||
$sample = $result['1.5.1'];
|
||||
$this->assertEquals('Improved signature with the Test::method()', $sample[0]);
|
||||
$this->assertEquals('Translation updates.', $sample[1]);
|
||||
|
||||
/*
|
||||
* Test junk file
|
||||
*/
|
||||
@ -92,7 +101,7 @@ class VersionManagerTest extends TestCase
|
||||
$manager = VersionManager::instance();
|
||||
$result = self::callProtectedMethod($manager, 'getNewFileVersions', ['\Winter\\Tester', '1.0.3']);
|
||||
|
||||
$this->assertCount(8, $result);
|
||||
$this->assertCount(10, $result);
|
||||
$this->assertArrayHasKey('1.0.4', $result);
|
||||
$this->assertArrayHasKey('1.0.5', $result);
|
||||
$this->assertArrayHasKey('1.1.0', $result);
|
||||
@ -101,6 +110,8 @@ class VersionManagerTest extends TestCase
|
||||
$this->assertArrayHasKey('1.3.1', $result);
|
||||
$this->assertArrayHasKey('1.3.2', $result);
|
||||
$this->assertArrayHasKey('1.4.1', $result);
|
||||
$this->assertArrayHasKey('1.5.0', $result);
|
||||
$this->assertArrayHasKey('1.5.1', $result);
|
||||
|
||||
/*
|
||||
* When at version 0, should return everything
|
||||
@ -108,7 +119,7 @@ class VersionManagerTest extends TestCase
|
||||
$manager = VersionManager::instance();
|
||||
$result = self::callProtectedMethod($manager, 'getNewFileVersions', ['\Winter\\Tester']);
|
||||
|
||||
$this->assertCount(11, $result);
|
||||
$this->assertCount(13, $result);
|
||||
$this->assertArrayHasKey('1.0.1', $result);
|
||||
$this->assertArrayHasKey('1.0.2', $result);
|
||||
$this->assertArrayHasKey('1.0.3', $result);
|
||||
@ -120,6 +131,8 @@ class VersionManagerTest extends TestCase
|
||||
$this->assertArrayHasKey('1.3.1', $result);
|
||||
$this->assertArrayHasKey('1.3.2', $result);
|
||||
$this->assertArrayHasKey('1.4.1', $result);
|
||||
$this->assertArrayHasKey('1.5.0', $result);
|
||||
$this->assertArrayHasKey('1.5.1', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user