Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Sep 1, 2016
1 parent 6d785c8 commit 47349b0
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
15 changes: 8 additions & 7 deletions plugins/Goals/tests/Integration/APITest.php
Expand Up @@ -50,23 +50,23 @@ public function test_addGoal_shouldReturnGoalId_IfCreationIsSuccessful()

public function test_addGoal_shouldSucceed_IfOnlyMinimumFieldsGiven()
{
$idGoal = $this->api->addGoal($this->idSite, 'MyName', 'url', 'http://www.test.de/?pk_campaign=1', 'exact');
$idGoal = $this->api->addGoal($this->idSite, 'MyName', 'url', 'http://www.test.de/?pk_campaign=1', 'exact', false, false, false, 'test description');

$this->assertGoal($idGoal, 'MyName', 'url', 'http://www.test.de/?pk_campaign=1', 'exact', 0, 0, 0);
$this->assertGoal($idGoal, 'MyName', 'test description', 'url', 'http://www.test.de/?pk_campaign=1', 'exact', 0, 0, 0);
}

public function test_addGoal_ShouldSucceed_IfAllFieldsGiven()
{
$idGoal = $this->api->addGoal($this->idSite, 'MyName', 'url', 'http://www.test.de', 'exact', true, 50, true);

$this->assertGoal($idGoal, 'MyName', 'url', 'http://www.test.de', 'exact', 1, 50, 1);
$this->assertGoal($idGoal, 'MyName', '', 'url', 'http://www.test.de', 'exact', 1, 50, 1);
}

public function test_addGoal_ShouldSucceed_IfExactPageTitle()
{
$idGoal = $this->api->addGoal($this->idSite, 'MyName', 'title', 'normal title', 'exact', true, 50, true);

$this->assertGoal($idGoal, 'MyName', 'title', 'normal title', 'exact', 1, 50, 1);
$this->assertGoal($idGoal, 'MyName', '', 'title', 'normal title', 'exact', 1, 50, 1);
}

/**
Expand Down Expand Up @@ -143,15 +143,15 @@ public function test_updateGoal_shouldUpdateAllGivenFields()
$idGoal = $this->createAnyGoal();
$this->api->updateGoal($this->idSite, $idGoal, 'UpdatedName', 'file', 'http://www.updatetest.de', 'contains', true, 999, true);

$this->assertGoal($idGoal, 'UpdatedName', 'file', 'http://www.updatetest.de', 'contains', 1, 999, 1);
$this->assertGoal($idGoal, 'UpdatedName', '', 'file', 'http://www.updatetest.de', 'contains', 1, 999, 1);
}

public function test_updateGoal_shouldUpdateMinimalFields_ShouldLeaveOtherFieldsUntouched()
{
$idGoal = $this->createAnyGoal();
$this->api->updateGoal($this->idSite, $idGoal, 'UpdatedName', 'file', 'http://www.updatetest.de', 'contains');

$this->assertGoal($idGoal, 'UpdatedName', 'file', 'http://www.updatetest.de', 'contains', 0, 0, 0);
$this->assertGoal($idGoal, 'UpdatedName', '', 'file', 'http://www.updatetest.de', 'contains', 0, 0, 0);
}

public function test_deleteGoal_shouldNotDeleteAGoal_IfGoalIdDoesNotExist()
Expand Down Expand Up @@ -235,12 +235,13 @@ private function assertHasNoGoals()
$this->assertEmpty($goals);
}

private function assertGoal($idGoal, $name, $url, $pattern, $patternType, $caseSenstive = 0, $revenue = 0, $allowMultiple = 0)
private function assertGoal($idGoal, $name, $description, $url, $pattern, $patternType, $caseSenstive = 0, $revenue = 0, $allowMultiple = 0)
{
$expected = array($idGoal => array(
'idsite' => $this->idSite,
'idgoal' => $idGoal,
'name' => $name,
'description' => $description,
'match_attribute' => $url,
'pattern' => $pattern,
'pattern_type' => $patternType,
Expand Down
Expand Up @@ -4,6 +4,7 @@
<idsite>1</idsite>
<idgoal>1</idgoal>
<name>all</name>
<description />
<match_attribute>url</match_attribute>
<pattern>http</pattern>
<pattern_type>contains</pattern_type>
Expand Down
Expand Up @@ -4,6 +4,7 @@
<idsite>1</idsite>
<idgoal>1</idgoal>
<name>triggered js</name>
<description />
<match_attribute>manually</match_attribute>
<allow_multiple>0</allow_multiple>
<revenue>0</revenue>
Expand All @@ -13,6 +14,7 @@
<idsite>1</idsite>
<idgoal>2</idgoal>
<name>matching purchase.htm</name>
<description />
<match_attribute>url</match_attribute>
<pattern>(.*)store\/purchase\.(.*)</pattern>
<pattern_type>regex</pattern_type>
Expand Down
Expand Up @@ -4,6 +4,7 @@
<idsite>1</idsite>
<idgoal>1</idgoal>
<name>triggered js</name>
<description />
<match_attribute>manually</match_attribute>
<allow_multiple>0</allow_multiple>
<revenue>0</revenue>
Expand All @@ -13,6 +14,7 @@
<idsite>1</idsite>
<idgoal>2</idgoal>
<name>matching purchase.htm</name>
<description />
<match_attribute>url</match_attribute>
<pattern>(.*)store\/purchase\.(.*)</pattern>
<pattern_type>regex</pattern_type>
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion tests/resources/OmniFixture-dump.sql
Expand Up @@ -179,6 +179,7 @@ CREATE TABLE `goal` (
`idsite` int(11) NOT NULL,
`idgoal` int(11) NOT NULL,
`name` varchar(50) NOT NULL,
`description` VARCHAR(255) NOT NULL DEFAULT '',
`match_attribute` varchar(20) NOT NULL,
`pattern` varchar(255) NOT NULL,
`pattern_type` varchar(10) NOT NULL,
Expand All @@ -196,7 +197,7 @@ CREATE TABLE `goal` (

LOCK TABLES `goal` WRITE;
/*!40000 ALTER TABLE `goal` DISABLE KEYS */;
INSERT INTO `goal` VALUES (1,1,'<script>$(\'body\').html(\'goal name XSS!\');</script>','url','http','contains',0,1,5,0),(1,2,'two','url','xxxxxxxxxxxxx','contains',0,0,5,0),(1,3,'click event','event_action','click','contains',0,0,0,0),(1,4,'category event','event_category','The_Category','exact',1,0,0,0),(1,5,'name event','event_name','<the_\'\"name>','exact',0,0,0,0);
INSERT INTO `goal` VALUES (1,1,'<script>$(\'body\').html(\'goal name XSS!\');</script>','<script>$(\'body\').html(\'goal description XSS!\');</script>','url','http','contains',0,1,5,0),(1,2,'two','twodesc','url','xxxxxxxxxxxxx','contains',0,0,5,0),(1,3,'click event','','event_action','click','contains',0,0,0,0),(1,4,'category event','categorydesc','event_category','The_Category','exact',1,0,0,0),(1,5,'name event','eventdesc','event_name','<the_\'\"name>','exact',0,0,0,0);
/*!40000 ALTER TABLE `goal` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down

0 comments on commit 47349b0

Please sign in to comment.