/** * Tests that the string representation of this object is as expected. */ public function testStringification() { $segment = new GaDataSegment(new GaDataSegmentConditionGroup(new GaDataSegmentSimpleCondition('foo', GaDataSegmentSimpleCondition::OP_EQ, 'bar')), GaDataSegment::SCOPE_SESSIONS); $this->assertEquals('sessions::condition::ga:foo==bar', (string) $segment); $sequence = new GaDataSegmentSequence(new GaDataSegmentSequenceCondition('foo', GaDataSegmentSequenceCondition::OP_IN, array('bar', 'baz')), new GaDataSegmentSequenceCondition('baz', GaDataSegmentSequenceCondition::OP_GT, '3', GaDataSegmentSequenceCondition::OP_FOLLOWED_BY)); $sequence->isNegated(true); $conditions = new GaDataSegmentConditionGroup(new GaDataSegmentSimpleCondition('bar', GaDataSegmentSimpleCondition::OP_CONTAINS, 'a')); $conditions->setScope(GaDataSegmentConditionGroup::SCOPE_PER_HIT); $segment = new GaDataSegment($sequence, GaDataSegment::SCOPE_USERS, $conditions, GaDataSegment::SCOPE_SESSIONS); $this->assertEquals('users::sequence::!ga:foo[]bar|baz;->>ga:baz>3;sessions::condition::perHit::ga:bar=@a', (string) $segment); }
/** * Tests that the string representation of this object is as expected. */ public function testStringification() { $sequence = new GaDataSegmentSequence(new GaDataSegmentSequenceCondition('foo', GaDataSegmentSequenceCondition::OP_EQ, 'bar')); $this->assertEquals('sequence::ga:foo==bar', (string) $sequence); $sequence->isNegated(true); $this->assertEquals('sequence::!ga:foo==bar', (string) $sequence); $sequence = new GaDataSegmentSequence(new GaDataSegmentSequenceCondition('foo', GaDataSegmentSequenceCondition::OP_LT, '3', GaDataSegmentSequenceCondition::OP_FIRST_HIT_MATCHES_FIRST_STEP), new GaDataSegmentSequenceCondition('bar', GaDataSegmentSequenceCondition::OP_BETWEEN, '1_10', GaDataSegmentSequenceCondition::OP_FOLLOWED_BY), new GaDataSegmentSequenceCondition('baz', GaDataSegmentSequenceCondition::OP_REGEXP, 'asdf', GaDataSegmentSequenceCondition::OP_FOLLOWED_BY_IMMEDIATE)); $this->assertEquals('sequence::^ga:foo<3;->>ga:bar<>1_10;->ga:baz=~asdf', (string) $sequence); $sequence = new GaDataSegmentSequence(new GaDataSegmentSequenceCondition('foo', GaDataSegmentSequenceCondition::OP_LT, '2015-01-01'), new GaDataSegmentSequenceCondition('dateOfSession', GaDataSegmentSequenceCondition::OP_NE, '2010-01-01'), new GaDataSegmentSequenceCondition('baz', GaDataSegmentSequenceCondition::OP_NOT_REGEXP, 'asdf', GaDataSegmentSequenceCondition::OP_FOLLOWED_BY)); $sequence->isNegated(true); $this->assertEquals('sequence::!ga:foo<2015-01-01;dateOfSession!=2010-01-01;->>ga:baz!~asdf', (string) $sequence); }