diff --git a/tests/PHPUnit/Core/PluginsFunctions/WidgetsListTest.php b/tests/PHPUnit/Core/PluginsFunctions/WidgetsListTest.php index c281933438cd91dd744d9f19532ea1aab6cbdf07..de769c5f15d2ecc801e69ea44557c496090d87ea 100644 --- a/tests/PHPUnit/Core/PluginsFunctions/WidgetsListTest.php +++ b/tests/PHPUnit/Core/PluginsFunctions/WidgetsListTest.php @@ -128,5 +128,69 @@ class WidgetsListTest extends DatabaseTestCase } } + /** + * @group Core + */ + public function testRemove() + { + // setup the access layer + $pseudoMockAccess = new FakeAccess; + FakeAccess::$superUser = true; + Access::setSingletonInstance($pseudoMockAccess); + + Test_Piwik_BaseFixture::createWebsite('2009-01-04 00:11:42', true); + API::getInstance()->addGoal(1, 'Goal 1 - Thank you', 'title', 'Thank you', 'contains', $caseSensitive = false, $revenue = 10, $allowMultipleConversions = 1); + + $_GET['idSite'] = 1; + + IntegrationTestCase::loadAllPlugins(); + + WidgetsList::_reset(); + $widgets = WidgetsList::get(); + + $this->assertCount(13, $widgets); + WidgetsList::remove('SEO', 'NoTeXiStInG'); + + $widgets = WidgetsList::get(); + $this->assertCount(13, $widgets); + + $this->assertArrayHasKey('SEO', $widgets); + $this->assertCount(2, $widgets['SEO']); + + WidgetsList::remove('SEO', 'SEO_SeoRankings'); + $widgets = WidgetsList::get(); + + $this->assertCount(1, $widgets['SEO']); + WidgetsList::remove('SEO'); + $widgets = WidgetsList::get(); + + $this->assertArrayNotHasKey('SEO', $widgets); + + WidgetsList::_reset(); + } + + + /** + * @group Core + */ + public function testIsDefined() + { + // setup the access layer + $pseudoMockAccess = new FakeAccess; + FakeAccess::$superUser = true; + Access::setSingletonInstance($pseudoMockAccess); + + \Piwik\Translate::loadEnglishTranslation(); + + Test_Piwik_BaseFixture::createWebsite('2009-01-04 00:11:42', true); + + $_GET['idSite'] = 1; + + WidgetsList::_reset(); + WidgetsList::add('Actions', 'Pages', 'Actions', 'getPageUrls'); + + $this->assertTrue(WidgetsList::isDefined('Actions', 'getPageUrls')); + $this->assertFalse(WidgetsList::isDefined('Actions', 'inValiD')); + } }