diff options
-rw-r--r-- | plugins/SegmentEditor/tests/Integration/SegmentEditorTest.php | 23 | ||||
-rw-r--r-- | tests/PHPUnit/System/VisitsInPastInvalidateOldReportsTest.php | 28 |
2 files changed, 25 insertions, 26 deletions
diff --git a/plugins/SegmentEditor/tests/Integration/SegmentEditorTest.php b/plugins/SegmentEditor/tests/Integration/SegmentEditorTest.php index 95ed3c12bb..d6b594280d 100644 --- a/plugins/SegmentEditor/tests/Integration/SegmentEditorTest.php +++ b/plugins/SegmentEditor/tests/Integration/SegmentEditorTest.php @@ -43,9 +43,6 @@ class SegmentEditorTest extends IntegrationTestCase APISitesManager::getInstance()->addSite('test', 'http://example.org'); } - /** - * @group Plugins - */ public function testAddInvalidSegment_ShouldThrow() { $this->expectException(\Exception::class); @@ -57,9 +54,6 @@ class SegmentEditorTest extends IntegrationTestCase $this->fail("Exception not raised."); } - /** - * @group Plugins - */ public function test_AddAndGet_SimpleSegment() { $name = 'name'; @@ -83,9 +77,6 @@ class SegmentEditorTest extends IntegrationTestCase $this->assertEquals($segment, $expected); } - /** - * @group Plugins - */ public function test_AddAndGet_AnotherSegment() { Rules::setBrowserTriggerArchiving(false); @@ -118,21 +109,14 @@ class SegmentEditorTest extends IntegrationTestCase $this->assertEquals($segments, array($expected)); // There is no segment to process for a non existing site - try { - $model->getSegmentsToAutoArchive(33); - $this->fail(); - } catch(Exception $e) { - // expected - } + $segments = $model->getSegmentsToAutoArchive(33); + $this->assertEquals($segments, array()); // There is no segment to process across all sites $segments = $model->getSegmentsToAutoArchive($idSite = false); $this->assertEquals($segments, array()); } - /** - * @group Plugins - */ public function test_UpdateSegment() { Rules::setBrowserTriggerArchiving(false); @@ -176,9 +160,6 @@ class SegmentEditorTest extends IntegrationTestCase $this->assertEquals($newSegment['name'], $nameSegment1); } - /** - * @group Plugins - */ public function test_deleteSegment() { Rules::setBrowserTriggerArchiving(false); diff --git a/tests/PHPUnit/System/VisitsInPastInvalidateOldReportsTest.php b/tests/PHPUnit/System/VisitsInPastInvalidateOldReportsTest.php index 2324cd63b8..b36268caae 100644 --- a/tests/PHPUnit/System/VisitsInPastInvalidateOldReportsTest.php +++ b/tests/PHPUnit/System/VisitsInPastInvalidateOldReportsTest.php @@ -8,6 +8,7 @@ namespace Piwik\Tests\System; use Piwik\API\Request; +use Piwik\Tests\Framework\Mock\FakeAccess; use Piwik\Tests\Framework\TestCase\SystemTestCase; use Piwik\Tests\Fixtures\TwoSitesVisitsInPast; use Exception; @@ -99,18 +100,28 @@ class VisitsInPastInvalidateOldReportsTest extends SystemTestCase // Make an invalid call $idSiteNoAccess = 777; try { - $request = new Request("module=API&method=CoreAdminHome.invalidateArchivedReports&idSites=" . $idSiteNoAccess . "&dates=2010-03-03&format=original"); + FakeAccess::clearAccess(); + $request = new Request("module=API&method=CoreAdminHome.invalidateArchivedReports&idSites=" . $idSiteNoAccess . "&dates=2010-03-03&format=original&token_auth=" . self::$fixture::VIEW_USER_TOKEN); $request->process(); - $this->fail(); - } catch(Exception $e) {} + $this->fail('Invalidating archived reports with invalid idSite worked, but shouldn\'t'); + } catch(\PHPUnit\Framework\Exception $e) { + throw $e; + } catch(Exception $e) { + $this->assertStringContainsString('checkUserHasAdminAccess Fake exception', $e->getMessage()); + } + FakeAccess::clearAccess(true); // test an invalidate period parameter try { $invalidPeriod = "day,month"; $request = new Request("module=API&method=CoreAdminHome.invalidateArchivedReports&period=$invalidPeriod&idSites=$idSite&dates=2010-03-03&format=original"); $request->process(); - $this->fail(); - } catch(Exception $e) {} + $this->fail('Invalidating archived reports with an invalid period worked, but shouldn\'t'); + } catch(\PHPUnit\Framework\Exception $e) { + throw $e; + } catch(Exception $e) { + $this->assertStringContainsString("The period 'day,month' is not supported", $e->getMessage()); + } // 2) Call API again, with an older date, which should now return data $this->runApiTests($api, $params); @@ -145,6 +156,13 @@ class VisitsInPastInvalidateOldReportsTest extends SystemTestCase ); } + public function provideContainerConfig() + { + return array( + 'Piwik\Access' => new FakeAccess() + ); + } + public static function getOutputPrefix() { return 'VisitsInPast_InvalidateOldReports'; |