Additional test cases and fixes for Version Yaml parser

This commit is contained in:
Ben Thomson 2022-03-01 09:05:45 +08:00
parent 05b941e72b
commit 9a800ad656
3 changed files with 22 additions and 5 deletions

View File

@ -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));

View File

@ -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.

View File

@ -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);
}
/**