Download plugins/Bandwidth/tests/Framework/TestCase/IntegrationTestCase.php from Leon4gr45/matomo: direct link, hf CLI and curl.
- Browser
- Download file 2.96 kB
-
https://huggingface.co/spaces/Leon4gr45/matomo/resolve/main/plugins/Bandwidth/tests/Framework/TestCase/IntegrationTestCase.php
- Command line
-
hf download hf://spaces/Leon4gr45/matomo/plugins/Bandwidth/tests/Framework/TestCase/IntegrationTestCase.php
-
curl -L -o IntegrationTestCase.php https://huggingface.co/spaces/Leon4gr45/matomo/resolve/main/plugins/Bandwidth/tests/Framework/TestCase/IntegrationTestCase.php
2.96 kB
| /** | |
| * Matomo - 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\Bandwidth\tests\Framework\TestCase; | |
| use Piwik\DataAccess\ArchiveTableCreator; | |
| use Piwik\Db; | |
| use Piwik\Plugin; | |
| use Piwik\Tests\Framework\Fixture; | |
| use Piwik\Tests\Framework\Mock\FakeAccess; | |
| /** | |
| * @group Bandwidth | |
| */ | |
| class IntegrationTestCase extends \Piwik\Tests\Framework\TestCase\IntegrationTestCase | |
| { | |
| protected $date; | |
| public function setUp(): void | |
| { | |
| parent::setUp(); | |
| $this->setSuperUser(); | |
| Fixture::createSuperUser(); | |
| Fixture::createWebsite('2014-01-01 00:00:00'); | |
| Plugin\Manager::getInstance()->loadPlugin('Bandwidth'); | |
| try { | |
| Plugin\Manager::getInstance()->activatePlugin('Bandwidth'); | |
| } catch (\Exception $e) { | |
| } | |
| } | |
| public function tearDown(): void | |
| { | |
| // clean up your test here if needed | |
| $tables = ArchiveTableCreator::getTablesArchivesInstalled(); | |
| if (!empty($tables)) { | |
| Db::dropTables($tables); | |
| } | |
| parent::tearDown(); | |
| } | |
| protected function setUser() | |
| { | |
| FakeAccess::$superUser = false; | |
| FakeAccess::$idSitesView = [1]; | |
| FakeAccess::$identity = 'aUser'; | |
| } | |
| protected function setSuperUser() | |
| { | |
| FakeAccess::$superUser = true; | |
| } | |
| protected function setAnonymousUser() | |
| { | |
| FakeAccess::clearAccess(); | |
| FakeAccess::$identity = 'anonymous'; | |
| } | |
| protected function getTracker() | |
| { | |
| $tracker = Fixture::getTracker(1, $this->date . ' 00:01:01', true, true); | |
| $tracker->setTokenAuth(Fixture::getTokenAuth()); | |
| return $tracker; | |
| } | |
| protected function trackPageviews($bytes) | |
| { | |
| $tracker = $this->getTracker(); | |
| foreach ($bytes as $byte) { | |
| $this->trackPageview($tracker, $byte); | |
| } | |
| } | |
| protected function trackPageview($tracker, $byte, $url = null) | |
| { | |
| if (null !== $url) { | |
| $tracker->setUrl('http://www.example.org' . $url); | |
| } | |
| if (null === $byte) { | |
| $tracker->setDebugStringAppend(''); | |
| } else { | |
| $tracker->setDebugStringAppend('bw_bytes=' . $byte); | |
| } | |
| $title = $url ?: 'test'; | |
| $tracker->doTrackPageView($title); | |
| } | |
| protected function trackDownloads($bytes) | |
| { | |
| $tracker = $this->getTracker(); | |
| foreach ($bytes as $byte) { | |
| if (null === $byte) { | |
| $tracker->setDebugStringAppend(''); | |
| } else { | |
| $tracker->setDebugStringAppend('bw_bytes=' . $byte); | |
| } | |
| $tracker->doTrackAction('http://www.example.com/test', 'download'); | |
| } | |
| } | |
| public function provideContainerConfig() | |
| { | |
| return [ | |
| 'Piwik\Access' => new FakeAccess(), | |
| ]; | |
| } | |
| } | |