Skip to content

Commit

Permalink
Add unit tests for #5271
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Thomson committed Sep 11, 2020
1 parent 4c41eee commit e7b1862
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
Empty file.
5 changes: 5 additions & 0 deletions tests/fixtures/plugins/october/tester/updates/version.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
1.2.0:
- "!!! Security update - see: https://octobercms.com"
1.1.0:
- !!! Drop support for blog settings
- drop_blog_settings_table.php
1.0.5:
- Create blog settings table
- Another update message
Expand Down
24 changes: 18 additions & 6 deletions tests/unit/system/classes/VersionManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,32 @@ public function testGetLatestFileVersion()
$result = self::callProtectedMethod($manager, 'getLatestFileVersion', ['\October\\Tester']);

$this->assertNotNull($result);
$this->assertEquals('1.0.5', $result);
$this->assertEquals('1.2.0', $result);
}

public function testGetFileVersions()
{
$manager = VersionManager::instance();
$result = self::callProtectedMethod($manager, 'getFileVersions', ['\October\\Tester']);

$this->assertCount(5, $result);
$this->assertCount(7, $result);
$this->assertArrayHasKey('1.0.1', $result);
$this->assertArrayHasKey('1.0.2', $result);
$this->assertArrayHasKey('1.0.3', $result);
$this->assertArrayHasKey('1.0.4', $result);
$this->assertArrayHasKey('1.0.5', $result);
$this->assertArrayHasKey('1.1.0', $result);
$this->assertArrayHasKey('1.2.0', $result);

$sample = $result['1.0.1'];
$comment = array_shift($sample);
$this->assertEquals("Added some upgrade file and some seeding", $comment);
$this->assertEquals('Added some upgrade file and some seeding', $sample[0]);

$sample = $result['1.1.0'];
$this->assertEquals('!!! Drop support for blog settings', $sample[0]);
$this->assertEquals('drop_blog_settings_table.php', $sample[1]);

$sample = $result['1.2.0'];
$this->assertEquals('!!! Security update - see: https://octobercms.com', $sample[0]);

/*
* Test junk file
Expand Down Expand Up @@ -70,22 +78,26 @@ public function testGetNewFileVersions()
$manager = VersionManager::instance();
$result = self::callProtectedMethod($manager, 'getNewFileVersions', ['\October\\Tester', '1.0.3']);

$this->assertCount(2, $result);
$this->assertCount(4, $result);
$this->assertArrayHasKey('1.0.4', $result);
$this->assertArrayHasKey('1.0.5', $result);
$this->assertArrayHasKey('1.1.0', $result);
$this->assertArrayHasKey('1.2.0', $result);

/*
* When at version 0, should return everything
*/
$manager = VersionManager::instance();
$result = self::callProtectedMethod($manager, 'getNewFileVersions', ['\October\\Tester']);

$this->assertCount(5, $result);
$this->assertCount(7, $result);
$this->assertArrayHasKey('1.0.1', $result);
$this->assertArrayHasKey('1.0.2', $result);
$this->assertArrayHasKey('1.0.3', $result);
$this->assertArrayHasKey('1.0.4', $result);
$this->assertArrayHasKey('1.0.5', $result);
$this->assertArrayHasKey('1.1.0', $result);
$this->assertArrayHasKey('1.2.0', $result);
}

/**
Expand Down

0 comments on commit e7b1862

Please sign in to comment.