public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     // note: not sure why I have to manually install plugin
     \Piwik\Plugin\Manager::getInstance()->loadPlugin('CustomAlerts')->install();
     $result = Fixture::updateDatabase();
     if ($result === false) {
         throw new \Exception("Failed to update pre-2.0 database (nothing to update).");
     }
     // truncate log tables so old data won't be re-archived
     foreach (array('log_visit', 'log_link_visit_action', 'log_conversion', 'log_conversion_item') as $table) {
         Db::query("TRUNCATE TABLE " . Common::prefixTable($table));
     }
     // add two visits from same visitor on dec. 29
     $t = Fixture::getTracker(1, '2012-12-29 01:01:30', $defaultInit = true);
     $t->setUrl('http://site.com/index.htm');
     $t->setIp('136.5.3.2');
     Fixture::checkResponse($t->doTrackPageView('incredible title!'));
     $t->setForceVisitDateTime('2012-12-29 03:01:30');
     $t->setUrl('http://site.com/other/index.htm');
     $t->DEBUG_APPEND_URL = '&_idvc=2';
     // make sure visit is marked as returning
     Fixture::checkResponse($t->doTrackPageView('other incredible title!'));
     // launch archiving
     VisitFrequencyApi::getInstance()->get(1, 'year', '2012-12-29');
 }
Example #2
0
 public function testUpdateWorksAfterPiwikIsAlreadyUpToDate()
 {
     $result = Fixture::updateDatabase($force = true);
     if ($result === false) {
         throw new \Exception("Failed to force update (nothing to update).");
     }
 }
Example #3
0
 public function setUp()
 {
     parent::setUp();
     $this->api = API::getInstance();
     Fixture::createWebsite('2014-01-01 00:00:00');
     Fixture::createWebsite('2014-01-01 00:00:00');
 }
 public function setUp()
 {
     // add one thousand sites
     $allIdSites = array();
     for ($i = 0; $i < 1000; ++$i) {
         $allIdSites[] = Fixture::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #{$i}");
     }
     $urls = array();
     for ($i = 0; $i != 3; ++$i) {
         $url = "http://whatever.com/" . ($i - 1) . "/" . ($i + 1);
         $title = "page view " . ($i - 1) . " / " . ($i + 1);
         $urls[$url] = $title;
     }
     $visitTimes = array();
     $date = Date::factory($this->date);
     for ($i = 0; $i != 4; ++$i) {
         $visitTimes[] = $date->addHour($i)->getDatetime();
     }
     // add 12000 visits (3 visitors with 4 visits each for each site) w/ 3 pageviews each on one day
     foreach ($visitTimes as $visitTime) {
         foreach ($allIdSites as $idSite) {
             for ($visitor = 0; $visitor != 3; ++$visitor) {
                 $t = BenchmarkTestCase::getLocalTracker($idSite);
                 $ip = "157.5.6." . ($visitor + 1);
                 $t->setIp($ip);
                 $t->setNewVisitorId();
                 $t->setForceVisitDateTime($visitTime);
                 foreach ($urls as $url => $title) {
                     $t->setUrl($url);
                     $t->doTrackPageView($title);
                 }
             }
         }
     }
 }
 public function setUp()
 {
     // add one site
     Fixture::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #0", $siteUrl = "http://whatever.com/");
     // add two goals
     $goals = API::getInstance();
     $goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
     $goals->addGoal($this->idSite, 'all', 'url', 'thing2', 'contains');
     $start = Date::factory($this->date);
     $dates = array();
     for ($day = 0; $day != 31; ++$day) {
         $dates[] = $start->addDay($day);
     }
     $t = BenchmarkTestCase::getLocalTracker($this->idSite);
     $actionNum = 0;
     foreach ($dates as $date) {
         for ($visitNum = 0; $visitNum != 1000; ++$visitNum) {
             if ($visitNum % 2 == 0) {
                 $url = "http://whatever.com/{$actionNum}/0/1/2/3/4/5/6/7/8/9";
                 $referrerUrl = "http://google.com/?q={$actionNum}";
             } else {
                 $url = "http://whatever.com/thing2/{$actionNum}/0/1/2/3/4/5/6/7/8/9";
                 $referrerUrl = "http://";
             }
             $title = "A page title / {$actionNum} / 0 / 1 / 2 / 3 / 4 / 5 / 6 / 7 / 8 /9";
             $t->setNewVisitorId();
             $t->setForceVisitDateTime($date);
             $t->setUrl($url);
             $t->setUrlReferrer($referrerUrl);
             Fixture::checkResponse($t->doTrackPageView($title));
             ++$actionNum;
         }
     }
 }
 public function getApiForTesting()
 {
     // we will test all segments from all plugins
     Fixture::loadAllPlugins();
     $apiToCall = array('VisitsSummary.get', 'CustomVariables.getCustomVariables');
     return array(array($apiToCall, array('idSite' => 'all', 'date' => self::$fixture->dateTime, 'periods' => array('day', 'week'), 'setDateLastN' => true, 'segment' => $this->getSegmentToTest())));
 }
Example #7
0
 public function testWebArchiving()
 {
     if (self::isMysqli() && self::isTravisCI()) {
         $this->markTestSkipped('Skipping on Mysqli as it randomly fails.');
     }
     $host = Fixture::getRootUrl();
     $token = Fixture::getTokenAuth();
     $urlTmp = Option::get('piwikUrl');
     Option::set('piwikUrl', $host . 'tests/PHPUnit/proxy/index.php');
     $url = $host . 'tests/PHPUnit/proxy/archive.php?token_auth=' . $token;
     $output = Http::sendHttpRequest($url, 600);
     // ignore random build issues
     if (empty($output) || strpos($output, \Piwik\CronArchive::NO_ERROR) === false) {
         $message = "This test has failed. Because it sometimes randomly fails, we skip the test, and ignore this failure.\n";
         $message .= "If you see this message often, or in every build, please investigate as this should only be a random and rare occurence!\n";
         $message .= "\n\narchive web failed: " . $output . "\n\nurl used: {$url}";
         $this->markTestSkipped($message);
     }
     if (!empty($urlTmp)) {
         Option::set('piwikUrl', $urlTmp);
     } else {
         Option::delete('piwikUrl');
     }
     $this->assertContains('Starting Piwik reports archiving...', $output);
     $this->assertContains('Archived website id = 1', $output);
     $this->assertContains('Done archiving!', $output);
     $this->compareArchivePhpOutputAgainstExpected($output);
 }
Example #8
0
 public function setUp()
 {
     parent::setUp();
     $pseudoMockAccess = new \FakeAccess();
     \FakeAccess::setSuperUserAccess(true);
     Access::setSingletonInstance($pseudoMockAccess);
     $idSite = Fixture::createWebsite('2014-01-01 00:00:00');
     $this->builder = $this->makeBuilder(array('method' => 'MultiSites_getAll', 'idSite' => $idSite));
 }
Example #9
0
function checkPiwikSetupForTests()
{
    if (empty($_SERVER['REQUEST_URI']) || $_SERVER['REQUEST_URI'] == '@REQUEST_URI@') {
        echo "WARNING: for tests to pass, you must first:\n1) Install webserver on localhost, eg. apache\n2) Make these Piwik files available on the webserver, at eg. http://localhost/dev/piwik/\n3) Install Piwik by going through the installation process\n4) Copy phpunit.xml.dist to phpunit.xml\n5) Edit in phpunit.xml the @REQUEST_URI@ and replace with the webserver path to Piwik, eg. '/dev/piwik/'\n\nTry again.\n-> If you still get this message, you can work around it by specifying Host + Request_Uri at the top of this file tests/PHPUnit/bootstrap.php. <-";
        exit(1);
    }
    $baseUrl = \Piwik\Tests\Fixture::getRootUrl();
    \Piwik\SettingsPiwik::checkPiwikServerWorking($baseUrl, $acceptInvalidSSLCertificates = true);
}
Example #10
0
 /**
  * @group Core
  * @dataProvider getMethodsToTest
  */
 public function testCustomByteRange($method)
 {
     $result = Http::sendHttpRequestBy($method, Fixture::getRootUrl() . '/piwik.js', 30, $userAgent = null, $destinationPath = null, $file = null, $followDepth = 0, $acceptLanguage = false, $acceptInvalidSslCertificate = false, $byteRange = array(10, 20), $getExtendedInfo = true);
     if ($method != 'fopen') {
         $this->assertEquals(206, $result['status']);
         $this->assertTrue(isset($result['headers']['Content-Range']));
         $this->assertEquals('bytes 10-20/', substr($result['headers']['Content-Range'], 0, 12));
         $this->assertEquals('application/x-javascript', $result['headers']['Content-Type']);
     }
 }
Example #11
0
 public function setUp()
 {
     parent::setUp();
     Fixture::createWebsite('2014-01-01 00:00:00');
     $this->unloadAllPlugins();
     $_GET['idSite'] = 1;
     $this->exampleReport = new GetExampleReport();
     $this->disabledReport = new GetDisabledReport();
     $this->basicReport = new GetBasicReport();
     $this->advancedReport = new GetAdvancedReport();
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $extraSite = Fixture::createWebsite(self::$fixture->dateTime, $ecommerce = 1, "the site");
     Piwik::addAction("ArchiveProcessor.Parameters.getIdSites", function (&$sites, $period) use($extraSite) {
         if (reset($sites) == $extraSite) {
             $sites = array(1, 2, 3);
         }
     });
     Config::getInstance()->General['enable_processing_unique_visitors_multiple_sites'] = 1;
 }
Example #13
0
 public function setUp()
 {
     parent::setUp();
     $this->reports = new ScheduledReports();
     $this->setIdentity('userlogin');
     for ($i = 1; $i <= 4; $i++) {
         Fixture::createWebsite('2014-01-01 00:00:00');
         $this->addReport('userlogin', $i);
     }
     $this->addReport('otherUser', 1);
     $this->addReport('anotherUser', 2);
 }
Example #14
0
 public function setUp()
 {
     parent::setUp();
     $this->api = API::getInstance();
     $pseudoMockAccess = new FakeAccess();
     FakeAccess::$superUser = true;
     Access::setSingletonInstance($pseudoMockAccess);
     Fixture::createWebsite('2014-01-01 00:00:00');
     Fixture::createWebsite('2014-01-01 00:00:00');
     Fixture::createWebsite('2014-01-01 00:00:00');
     $this->api->addUser('userLogin', 'password', '*****@*****.**');
 }
Example #15
0
 protected function makeTracker($idSite, $dateTime, $debugStringAppend = '')
 {
     $tracker = parent::getTracker($idSite, $dateTime, $defaultInit = true);
     if ($this->forceLargeWindowLookBackForVisitor) {
         // Fakes the config value window_look_back_for_visitor tested in TrackerWindowLookBack
         $debugStringAppend .= '&forceLargeWindowLookBackForVisitor=1';
         // Here we force the visitor ID cookie value sent to piwik.php, to create a "unique visitor" for all visits in fixture
         // we do not use setVisitorId(), because we want shouldLookupOneVisitorFieldOnly() to return false for this particular test case
         $debugStringAppend .= '&_id=2f4f673d4732e11d';
     }
     $tracker->setDebugStringAppend($debugStringAppend);
     return $tracker;
 }
 private function getResponseHeader($url)
 {
     if (!function_exists('curl_init')) {
         $this->markTestSkipped('Curl is not installed');
     }
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, Fixture::getRootUrl() . 'tests/PHPUnit/proxy/' . $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_HEADER, true);
     curl_setopt($ch, CURLOPT_TIMEOUT, 10);
     $response = curl_exec($ch);
     $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
     $header = substr($response, 0, $headerSize);
     curl_close($ch);
     return $header;
 }
 public function setUp()
 {
     for ($i = 0; $i != $this->siteCount; ++$i) {
         $idSite = Fixture::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #{$i}", $siteUrl = "http://site{$i}.com/");
         API::getInstance()->addGoal($idSite, 'all', 'url', 'http', 'contains', false, 5);
     }
     // track one visit for each site
     $t = BenchmarkTestCase::getLocalTracker(1);
     $t->setForceVisitDateTime(Date::factory($this->date)->addHour(6));
     for ($idSite = 1; $idSite < $this->siteCount + 1; ++$idSite) {
         $ip = "157.5.6.4";
         $t->setIp($ip);
         $t->setNewVisitorId();
         $t->setIdSite($idSite);
         $t->setUrl("http://site" . ($idSite - 1) . ".com/page.html");
         $t->doTrackPageView('page title');
     }
 }
Example #18
0
 protected function issueBulkTrackingRequest($token_auth, $expectTrackingToSucceed)
 {
     $piwikHost = Fixture::getRootUrl() . 'tests/PHPUnit/proxy/piwik.php';
     $command = 'curl -s -X POST -d \'{"requests":["?idsite=1&url=http://example.org&action_name=Test bulk log Pageview&rec=1","?idsite=1&url=http://example.net/test.htm&action_name=Another bulk page view&rec=1"],"token_auth":"' . $token_auth . '"}\' ' . $piwikHost;
     exec($command, $output, $result);
     if ($result !== 0) {
         throw new Exception("tracking bulk failed: " . implode("\n", $output) . "\n\ncommand used: {$command}");
     }
     $output = implode("", $output);
     $this->assertStringStartsWith('{"status":', $output);
     if ($expectTrackingToSucceed) {
         $this->assertNotContains('error', $output);
         $this->assertContains('success', $output);
     } else {
         $this->assertContains('error', $output);
         $this->assertNotContains('success', $output);
     }
 }
Example #19
0
 public function getApiForTesting()
 {
     // we will test all segments from all plugins
     Fixture::loadAllPlugins();
     $idSite = self::$fixture->idSite;
     $apiForTesting = array();
     $segments = \Piwik\Plugins\API\API::getInstance()->getSegmentsMetadata(self::$fixture->idSite);
     foreach ($segments as $segment) {
         $apiForTesting[] = $this->getApiForTestingForSegment($idSite, $segment['segment']);
     }
     if (self::isMysqli() || self::isTravisCI()) {
         // Skip the test on Mysqli as it fails due to rounding Float errors on latitude/longitude
         // then the test started failing after bc19503 and I cannot understand why
         echo "Skipped test \n";
     } else {
         $apiForTesting[] = array('Live.getLastVisitsDetails', array('idSite' => $idSite, 'date' => '1998-07-12,today', 'period' => 'range', 'otherRequestParameters' => array('filter_limit' => 1000)));
     }
     return $apiForTesting;
 }
 public function setUp()
 {
     // add one site
     Fixture::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #0", $siteUrl = "http://whatever.com/");
     // add two goals
     $goals = API::getInstance();
     $goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
     $goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains');
     $urls = array();
     for ($i = 0; $i != 3; ++$i) {
         $url = "http://whatever.com/" . ($i - 1) . "/" . ($i + 1);
         $title = "page view " . ($i - 1) . " / " . ($i + 1);
         $urls[$url] = $title;
     }
     $visitTimes = array();
     $date = Date::factory($this->date);
     for ($month = 0; $month != 12; ++$month) {
         for ($day = 0; $day != 25; ++$day) {
             $visitTimes[] = $date->addPeriod($month, 'MONTH')->addDay($day)->getDatetime();
         }
     }
     // add 12,000 visits (1 visit a day from 40 visitors for 25 days of every month) w/ 3 pageviews each
     foreach ($visitTimes as $visitTime) {
         for ($visitor = 0; $visitor != 40; ++$visitor) {
             $t = BenchmarkTestCase::getLocalTracker($this->idSite);
             $ip = "157.5.6." . ($visitor + 1);
             $t->setIp($ip);
             $t->setNewVisitorId();
             $t->setForceVisitDateTime($visitTime);
             foreach ($urls as $url => $title) {
                 $t->setUrl($url);
                 $t->doTrackPageView($title);
             }
         }
     }
 }
Example #21
0
 /**
  * Return 4 Api Urls for testing scheduled reports :
  * - one in HTML format with all available reports
  * - one in PDF format with all available reports
  * - two in SMS (one for each available report: MultiSites.getOne & MultiSites.getAll)
  *
  * @param string $dateTime eg '2010-01-01 12:34:56'
  * @param string $period eg 'day', 'week', 'month', 'year'
  * @return array
  */
 protected static function getApiForTestingScheduledReports($dateTime, $period)
 {
     $apiCalls = array();
     // HTML Scheduled Report
     array_push($apiCalls, array('ScheduledReports.generateReport', array('testSuffix' => '_scheduled_report_in_html_tables_only', 'date' => $dateTime, 'periods' => array($period), 'format' => 'original', 'fileExtension' => 'html', 'otherRequestParameters' => array('idReport' => 1, 'reportFormat' => ReportRenderer::HTML_FORMAT, 'outputType' => \Piwik\Plugins\ScheduledReports\API::OUTPUT_RETURN))));
     // CSV Scheduled Report
     array_push($apiCalls, array('ScheduledReports.generateReport', array('testSuffix' => '_scheduled_report_in_csv', 'date' => $dateTime, 'periods' => array($period), 'format' => 'original', 'fileExtension' => 'csv', 'otherRequestParameters' => array('idReport' => 1, 'reportFormat' => ReportRenderer::CSV_FORMAT, 'outputType' => \Piwik\Plugins\ScheduledReports\API::OUTPUT_RETURN))));
     if (Fixture::canImagesBeIncludedInScheduledReports()) {
         // PDF Scheduled Report
         // tests/PHPUnit/Integration/processed/test_ecommerceOrderWithItems_scheduled_report_in_pdf_tables_only__ScheduledReports.generateReport_week.original.pdf
         array_push($apiCalls, array('ScheduledReports.generateReport', array('testSuffix' => '_scheduled_report_in_pdf_tables_only', 'date' => $dateTime, 'periods' => array($period), 'format' => 'original', 'fileExtension' => 'pdf', 'otherRequestParameters' => array('idReport' => 1, 'reportFormat' => ReportRenderer::PDF_FORMAT, 'outputType' => \Piwik\Plugins\ScheduledReports\API::OUTPUT_RETURN))));
     }
     // SMS Scheduled Report, one site
     array_push($apiCalls, array('ScheduledReports.generateReport', array('testSuffix' => '_scheduled_report_via_sms_one_site', 'date' => $dateTime, 'periods' => array($period), 'format' => 'original', 'fileExtension' => 'sms.txt', 'otherRequestParameters' => array('idReport' => 2, 'outputType' => \Piwik\Plugins\ScheduledReports\API::OUTPUT_RETURN))));
     // SMS Scheduled Report, all sites
     array_push($apiCalls, array('ScheduledReports.generateReport', array('testSuffix' => '_scheduled_report_via_sms_all_sites', 'date' => $dateTime, 'periods' => array($period), 'format' => 'original', 'fileExtension' => 'sms.txt', 'otherRequestParameters' => array('idReport' => 3, 'outputType' => \Piwik\Plugins\ScheduledReports\API::OUTPUT_RETURN))));
     if (Fixture::canImagesBeIncludedInScheduledReports()) {
         // HTML Scheduled Report with images
         array_push($apiCalls, array('ScheduledReports.generateReport', array('testSuffix' => '_scheduled_report_in_html_tables_and_graph', 'date' => $dateTime, 'periods' => array($period), 'format' => 'original', 'fileExtension' => 'html', 'otherRequestParameters' => array('idReport' => 4, 'reportFormat' => ReportRenderer::HTML_FORMAT, 'outputType' => \Piwik\Plugins\ScheduledReports\API::OUTPUT_RETURN))));
         // mail report with one row evolution based png graph
         array_push($apiCalls, array('ScheduledReports.generateReport', array('testSuffix' => '_scheduled_report_in_html_row_evolution_graph', 'date' => $dateTime, 'periods' => array($period), 'format' => 'original', 'fileExtension' => 'html', 'otherRequestParameters' => array('idReport' => 5, 'outputType' => \Piwik\Plugins\ScheduledReports\API::OUTPUT_RETURN))));
     }
     return $apiCalls;
 }
Example #22
0
 /**
  * Helper methods
  */
 private function getStaticSrvUrl()
 {
     return Fixture::getRootUrl();
 }
Example #23
0
 private function createSite()
 {
     Fixture::createWebsite('2013-01-23 01:23:45');
 }
Example #24
0
 /**
  * @group Core
  */
 public function testIsDefined()
 {
     // setup the access layer
     $pseudoMockAccess = new FakeAccess();
     FakeAccess::$superUser = true;
     Access::setSingletonInstance($pseudoMockAccess);
     \Piwik\Translate::loadEnglishTranslation();
     Fixture::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'));
 }
Example #25
0
 protected static function _addLogData()
 {
     // tracks visits on the following days:
     // - 2012-01-09
     // - 2012-01-14
     // - 2012-01-19
     // - 2012-01-24 <--- everything before this date is to be purged
     // - 2012-01-29
     // - 2012-02-03
     // - 2012-02-08
     // - 2012-02-13
     // - 2012-02-18
     // - 2012-02-23
     // - 2012-02-28
     // 6 visits in feb, 5 in jan
     // following actions are created:
     // - 'First page view'
     // - 'Second page view'
     // - 'SKU2'
     // - 'Canon SLR'
     // - 'Electronics & Cameras'
     // - for every visit (11 visits total):
     //   - http://whatever.com/_{$daysSinceLastVisit}
     //   - http://whatever.com/42/{$daysSinceLastVisit}
     $start = Date::factory(self::$dateTime);
     self::$idSite = Fixture::createWebsite('2012-01-01', $ecommerce = 1);
     APIGoals::getInstance()->addGoal(self::$idSite, 'match all', 'url', 'http', 'contains');
     $t = Fixture::getTracker(self::$idSite, $start, $defaultInit = true);
     $t->enableBulkTracking();
     $t->setTokenAuth(Fixture::getTokenAuth());
     for ($daysAgo = self::$daysAgoStart; $daysAgo >= 0; $daysAgo -= 5) {
         $dateTime = $start->subDay($daysAgo)->toString();
         $t->setForceVisitDateTime($dateTime);
         $t->setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729)');
         // use $daysAgo to make sure new actions are created for every day and aren't used again.
         // when deleting visits, some of these actions will no longer be referenced in the DB.
         $t->setUrl("http://whatever.com/_{$daysAgo}");
         $t->doTrackPageView('First page view');
         $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.05));
         $t->setUrl("http://whatever.com/42/{$daysAgo}");
         $t->doTrackPageView('Second page view');
         $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.1));
         $t->setUrl("http://whatever.com/event");
         $t->doTrackEvent('Event action', 'event cat', 'daysAgo=' . $daysAgo, 1000);
         $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.2));
         $t->addEcommerceItem($sku = 'SKU2', $name = 'Canon SLR', $category = 'Electronics & Cameras', $price = 1500, $quantity = 1);
         $t->doTrackEcommerceOrder($orderId = '937nsjusu ' . $dateTime, $grandTotal = 1111.11, $subTotal = 1000, $tax = 111, $shipping = 0.11, $discount = 666);
     }
     Fixture::checkBulkTrackingResponse($t->doBulkTrack());
 }
Example #26
0
 public function setUp()
 {
     parent::setUp();
     Fixture::createWebsite('2014-01-01 00:00:00');
     Piwik::addAction('Tracker.Request.getIdSite', function (&$idSite) {
         $idSite = 1;
     });
 }
Example #27
0
 public function setUp()
 {
     parent::setUp();
     Fixture::createWebsite('2014-01-01 00:00:00');
 }
Example #28
0
 /**
  * Resets all caches and drops the database
  */
 public function tearDown()
 {
     parent::tearDown();
     $this->fixture->performTearDown();
 }
Example #29
0
 /**
  * Helper methods
  */
 private function getStaticSrvUrl()
 {
     $url = Fixture::getRootUrl();
     $url .= '/tests/resources/';
     return $url . "staticFileServer.php?" . FILE_MODE_REQUEST_VAR . "=" . STATIC_SERVER_MODE . "&" . SRV_MODE_REQUEST_VAR . "=";
 }
Example #30
0
 private function setupDatabaseOverrides(InputInterface $input, Fixture $fixture)
 {
     $testingEnvironment = $fixture->getTestEnvironment();
     $optionsToOverride = array('dbname' => $fixture->getDbName(), 'host' => $input->getOption('db-host'), 'username' => $input->getOption('db-user'), 'password' => $input->getOption('db-pass'));
     foreach ($optionsToOverride as $configOption => $value) {
         if ($value) {
             $configOverride = $testingEnvironment->configOverride;
             $configOverride['database_tests'][$configOption] = $configOverride['database'][$configOption] = $value;
             $testingEnvironment->configOverride = $configOverride;
             Config::getInstance()->database[$configOption] = $value;
         }
     }
 }