diff options
author | Stefan Giehl <stefan@matomo.org> | 2020-12-10 03:13:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-10 03:13:58 +0300 |
commit | 5706eabad6d1a6495ef12937f02cde0c8cda80cc (patch) | |
tree | b32368731cd3257f684bf042134857e3a3d36580 /plugins/Annotations | |
parent | 4d7b8566b4db6e0a118d316f0708a502e75cf6ab (diff) |
Rewrite Annotations tests to run correctly (#16926)
Diffstat (limited to 'plugins/Annotations')
-rw-r--r-- | plugins/Annotations/tests/System/AnnotationsTest.php | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/plugins/Annotations/tests/System/AnnotationsTest.php b/plugins/Annotations/tests/System/AnnotationsTest.php index 65b9dbcaf2..1b3b4dc6ee 100644 --- a/plugins/Annotations/tests/System/AnnotationsTest.php +++ b/plugins/Annotations/tests/System/AnnotationsTest.php @@ -264,30 +264,33 @@ class AnnotationsTest extends SystemTestCase */ public function testMethodPermissions($hasAdminAccess, $hasViewAccess, $request, $checkException, $failMessage) { + if (true === $checkException) { + self::expectException(Exception::class); + } else { + self::expectNotToPerformAssertions(); + } + // create fake access that denies user access - FakeAccess::$superUser = false; + FakeAccess::clearAccess(false); + FakeAccess::$identity = 'user' . (int)$hasAdminAccess . (int)$hasViewAccess; FakeAccess::$idSitesAdmin = $hasAdminAccess ? array(self::$fixture->idSite1) : array(); FakeAccess::$idSitesView = $hasViewAccess ? array(self::$fixture->idSite1) : array(); - if ($checkException) { - try { - $request = new Request($request); - $request->process(); - $this->fail($failMessage); - } catch (Exception $ex) { - $this->assertTrue(true); // pass - } - } else { - $request = new Request($request); - $request->process(); - - } + $request = new Request($request.'&format=original'); + $request->process(); } public static function getPathToTestDirectory() { return dirname(__FILE__); } + + public function provideContainerConfig() + { + return array( + 'Piwik\Access' => new FakeAccess() + ); + } } AnnotationsTest::$fixture = new TwoSitesWithAnnotations();
\ No newline at end of file |