From f1387bf5e08a562738953bfa3d01044e7488f2ff Mon Sep 17 00:00:00 2001
From: sgiehl <stefan@piwik.org>
Date: Sat, 26 Oct 2013 16:57:28 +0200
Subject: [PATCH] added some more tests

---
 .../Core/PluginsFunctions/WidgetsListTest.php | 64 +++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/tests/PHPUnit/Core/PluginsFunctions/WidgetsListTest.php b/tests/PHPUnit/Core/PluginsFunctions/WidgetsListTest.php
index c281933438..de769c5f15 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'));
+    }
 }
-- 
GitLab