コード例 #1
0
 /**
  * @depends testCreateAndGetAutoresponderItemActivityById
  */
 public function testGetByType()
 {
     $autoresponderItemActivities = AutoresponderItemActivity::getByType(AutoresponderItemActivity::TYPE_OPEN);
     $this->assertCount(1, $autoresponderItemActivities);
     $autoresponderItemActivities = AutoresponderItemActivity::getByType(AutoresponderItemActivity::TYPE_CLICK);
     $this->assertCount(2, $autoresponderItemActivities);
 }
コード例 #2
0
 /**
  * @depends testResolveQueryStringFromUrlAndCreateOrUpdateActivityThrowsExceptionForInvalidPersonIdForUrlClickTracking
  * @expectedException NotSupportedException
  */
 public function testResolveQueryStringFromUrlAndCreateOrUpdateActivityThrowsExceptionForDuplicateActivityForUrlClickTracking()
 {
     // setup pre-req data
     $autoresponderItemActivities = AutoresponderItemActivity::getByType(AutoresponderItemActivity::TYPE_CLICK);
     $this->assertNotEmpty($autoresponderItemActivities);
     $autoresponderActivity = new AutoresponderItemActivity();
     $autoresponderActivity->quantity = $autoresponderItemActivities[0]->quantity;
     $autoresponderActivity->type = $autoresponderItemActivities[0]->type;
     $autoresponderActivity->autoresponderItem = $autoresponderItemActivities[0]->autoresponderItem;
     $autoresponderActivity->person = $autoresponderItemActivities[0]->person;
     $autoresponderActivity->emailMessageUrl = $autoresponderItemActivities[0]->emailMessageUrl;
     $this->assertTrue($autoresponderActivity->save());
     $modelId = $autoresponderItemActivities[0]->autoresponderItem->id;
     $modelType = get_class($autoresponderItemActivities[0]->autoresponderItem);
     $personId = $autoresponderItemActivities[0]->person->id;
     // get the modelClassName to use for activity object tests
     $className = 'AutoresponderItemActivityUtil';
     $resolveModelClassNameByModelTypeFunction = static::getProtectedMethod($className, 'resolveModelClassNameByModelType');
     $modelClassName = $resolveModelClassNameByModelTypeFunction->invokeArgs(null, array($modelType));
     $type = $modelClassName::TYPE_CLICK;
     $existingActivities = $modelClassName::getByType($type);
     $this->assertCount(2, $existingActivities);
     // get base query string
     $resolveBaseQueryStringArrayFunction = static::getProtectedMethod('ContentTrackingUtil', 'resolveBaseQueryStringArray');
     $queryStringArray = $resolveBaseQueryStringArrayFunction->invokeArgs(null, array($modelId, $modelType, $personId));
     $this->assertNotEmpty($queryStringArray);
     $this->assertCount(3, $queryStringArray);
     $this->assertArrayHasKey('modelId', $queryStringArray);
     $this->assertArrayHasKey('modelType', $queryStringArray);
     $this->assertArrayHasKey('personId', $queryStringArray);
     $queryStringArray['url'] = 'http://www.zurmo.com';
     // get hash for query string and ensure its what we expect it to be.
     $queryStringArrayHash = StringUtil::resolveHashForQueryStringArray($queryStringArray);
     $queryStringArrayDecoded = $className::resolveQueryStringArrayForHash($queryStringArrayHash);
     $this->assertNotEmpty($queryStringArrayDecoded);
     $this->assertCount(5, $queryStringArrayDecoded);
     $this->assertArrayHasKey('modelId', $queryStringArrayDecoded);
     $this->assertArrayHasKey('modelType', $queryStringArrayDecoded);
     $this->assertArrayHasKey('personId', $queryStringArrayDecoded);
     $this->assertArrayHasKey('url', $queryStringArrayDecoded);
     $this->assertArrayHasKey('type', $queryStringArrayDecoded);
     $this->assertEquals($queryStringArray['modelId'], $queryStringArrayDecoded['modelId']);
     $this->assertEquals($queryStringArray['modelType'], $queryStringArrayDecoded['modelType']);
     $this->assertEquals($queryStringArray['personId'], $queryStringArrayDecoded['personId']);
     $this->assertEquals($queryStringArray['url'], $queryStringArrayDecoded['url']);
     $this->assertNull($queryStringArrayDecoded['type']);
     // do the magic, confirm magic worked by checking return value.
     $_GET['id'] = $queryStringArrayHash;
     $result = $className::resolveQueryStringFromUrlAndCreateOrUpdateActivity();
 }