channels = new Plugin\ReleaseChannels(StaticContainer::get('Piwik\Plugin\Manager')); } public function testGetAllReleaseChannelsShouldFindAllAvailableRelaseChannels() { $channels = $this->channels->getAllReleaseChannels(); $this->assertCount(5, $channels); foreach ($channels as $channel) { $this->assertTrue($channel instanceof ReleaseChannel); } } public function testGetAllReleaseChannelsShouldOrderChannelsByOrderId() { $channels = $this->channels->getAllReleaseChannels(); $lowest = 0; foreach ($channels as $channel) { $this->assertGreaterThanOrEqual($lowest, $channel->getOrder()); $lowest = $channel->getOrder(); } // to make sure we actually went into the for loop... $this->assertGreaterThan(0, $lowest); } /** * @dataProvider getTestValidReleaseChannelIds */ public function testIsValidReleaseChannelIdShouldDetectIfReleaseChannelIsCorrectOrNot($expectedExists, $id) { $this->assertSame($expectedExists, $this->channels->isValidReleaseChannelId($id)); } public function getTestValidReleaseChannelIds() { return array( array($exists = true, $id = 'latest_stable'), array($exists = true, $id = 'latest_beta'), array($exists = true, $id = 'latest_5x_stable'), array($exists = true, $id = 'latest_preview'), array($exists = true, $id = 'laTest_stable'), // we do not check for exact match array($exists = false, $id = ''), array($exists = false, $id = 'latest'), array($exists = false, $id = 'stable'), array($exists = false, $id = 'lateststable'), ); } public function getTestActiveReleaseChannel() { return array( array('latest_stable', 'latest_stable'), array('latest_4x_stable', 'latest_5x_stable'), array('latest_beta', 'latest_beta'), array('latest_beta', 'latEst_betA'), array('latest_stable', ''), // if nothing configured should return default (the one with lowest order) array('latest_stable', 'latest'), // if invalid id configured should return default (the one with lowest order) ); } }