Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 364dad51da
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 90 lines (73 sloc) 2.204 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
<?php
if(!defined('PIWIK_CONFIG_TEST_INCLUDED'))
{
require_once dirname(__FILE__)."/../../tests/config_test.php";
}

require_once PIWIK_INCLUDE_PATH . '/tests/integration/TwoVisitsWithCustomVariables.test.php';

/**
* testing a segment containing all supported fields
*/
class Test_Piwik_Integration_TwoVisitsWithCustomVariables_SegmentMatchNONE extends Test_Piwik_Integration_TwoVisitsWithCustomVariables
{
// set lazily so when testing, asserts can be run
private $segment = null;

public function __construct($title = '')
{
parent::__construct($title);
$this->doExtraQuoteTests = false;
}

public function getApiToTest()
{
$apiToCall = array('VisitsSummary.get', 'CustomVariables.getCustomVariables');

return array(
array($apiToCall, array('idSite' => 'all', 'date' => $this->dateTime, 'periods' => array('day', 'week'),
'setDateLastN' => true, 'segment' => $this->getSegmentToTest(false)))
);
}

public function getSegmentToTest($calledDuringTest)
{
if ($this->segment)
{
return $this->segment;
}

// Segment matching NONE
$segments = Piwik_API_API::getInstance()->getSegmentsMetadata($this->idSite);
$segmentExpression = array();

$seenVisitorId = false;
foreach($segments as $segment) {
$value = 'campaign';
if($segment['segment'] == 'visitorId')
{
$seenVisitorId = true;
$value = '34c31e04394bdc63';
}
if($segment['segment'] == 'visitEcommerceStatus')
{
$value = 'none';
}
$segmentExpression[] = $segment['segment'] .'!='.$value;
}

$this->segment = implode(";", $segmentExpression);

// just checking that this segment was tested (as it has the only visible to admin flag)
if ($calledDuringTest)
{
$this->assertTrue($seenVisitorId);
$this->assertTrue(strlen($this->segment) > 100);
}

return $this->segment;
}

public function getControllerActionsToTest()
{
return array();
}

public function getOutputPrefix()
{
return 'twoVisitsWithCustomVariables_segmentMatchNONE';
}

public function test_RunAllTests()
{
// get the segment used & make sure to do some extra tests before testing the API
$this->getSegmentToTest(true);

parent::test_RunAllTests();
}
}

Something went wrong with that request. Please try again.