diff options
author | Stefan Giehl <stefan@matomo.org> | 2020-04-23 10:43:30 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-23 10:43:30 +0300 |
commit | a8d917778e75346eab9509ac9707f7e6e2e6c58d (patch) | |
tree | 8259898ab33eb882e631f1f5475cd1482f70e402 /plugins/SegmentEditor/tests | |
parent | 0cdeb6da6e4679c56aa351c004cbd6afe7843c56 (diff) |
Refactores the way segments are configured in dimensions (#15836)
* Improve naming of methods for segments to rescrict access for anonymous user
* Introduce new classes SegmentsList nad DimensionSegmentFactory
* removes SegmentEditor\SegmentList and adds some tests
* submodule updates
Diffstat (limited to 'plugins/SegmentEditor/tests')
-rw-r--r-- | plugins/SegmentEditor/tests/Integration/SegmentFormatterTest.php | 8 | ||||
-rw-r--r-- | plugins/SegmentEditor/tests/Integration/SegmentListTest.php | 73 |
2 files changed, 4 insertions, 77 deletions
diff --git a/plugins/SegmentEditor/tests/Integration/SegmentFormatterTest.php b/plugins/SegmentEditor/tests/Integration/SegmentFormatterTest.php index a7db9f6666..0e0f250351 100644 --- a/plugins/SegmentEditor/tests/Integration/SegmentFormatterTest.php +++ b/plugins/SegmentEditor/tests/Integration/SegmentFormatterTest.php @@ -9,7 +9,7 @@ namespace Piwik\Plugins\SegmentEditor\tests\Integration; use Piwik\Plugins\SegmentEditor\SegmentFormatter; -use Piwik\Plugins\SegmentEditor\SegmentList; +use Piwik\Segment\SegmentsList; use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; @@ -32,10 +32,10 @@ class SegmentFormatterTest extends IntegrationTestCase { parent::setUp(); - $this->idSite = Fixture::createWebsite('2012-01-01 00:00:00'); - $this->formatter = new SegmentFormatter(new SegmentList()); - Fixture::loadAllTranslations(); + + $this->idSite = Fixture::createWebsite('2012-01-01 00:00:00'); + $this->formatter = new SegmentFormatter(SegmentsList::get()); } public function tearDown(): void diff --git a/plugins/SegmentEditor/tests/Integration/SegmentListTest.php b/plugins/SegmentEditor/tests/Integration/SegmentListTest.php deleted file mode 100644 index 3a66a4bd4e..0000000000 --- a/plugins/SegmentEditor/tests/Integration/SegmentListTest.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php -/** - * Piwik - free/libre analytics platform - * - * @link https://matomo.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */ - -namespace Piwik\Plugins\SegmentEditor\tests\Integration; - -use Piwik\Plugins\SegmentEditor\SegmentList; -use Piwik\Tests\Framework\Fixture; -use Piwik\Tests\Framework\Mock\FakeAccess; -use Piwik\Tests\Framework\TestCase\IntegrationTestCase; -use Exception; - -/** - * @group SegmentListTest - * @group SegmentList - * @group SegmentEditor - * @group Plugins - */ -class SegmentListTest extends IntegrationTestCase -{ - /** - * @var SegmentList - */ - private $list; - - private $idSite; - - public function setUp(): void - { - parent::setUp(); - - $this->idSite = Fixture::createWebsite('2012-01-01 00:00:00'); - $this->list = new SegmentList(); - } - - public function test_findSegment_shouldFindSegmentByName_IfNameExists() - { - $segmentName = 'pageUrl'; - - $segment = $this->list->findSegment($segmentName, $this->idSite); - self::assertIsArray($segment); - $this->assertSame($segmentName, $segment['segment']); - } - - public function test_findSegment_shouldNotFindSegmentByName_IfNameDoesNotExist() - { - $segment = $this->list->findSegment('aNyNotExisTinGSegmEnt', $this->idSite); - $this->assertNull($segment); - } - - public function test_findSegment_ShouldThrowException_IfNotEnoughPermission() - { - $this->expectException(\Exception::class); - $this->expectExceptionMessage('checkUserHasViewAccess'); - - FakeAccess::clearAccess($superUser = false, array(1)); - - $segment = $this->list->findSegment('pageUrl', 999); - $this->assertNull($segment); - } - - public function provideContainerConfig() - { - return array( - 'Piwik\Access' => new FakeAccess() - ); - } - -} |