/** * @inheritDoc */ protected function setUp() { parent::setUp(); $this->context = new GenericContext(array('Namespaced' => array('Number' => new GenericProperty(array('type' => new NumberType())), 'String' => new GenericProperty(array('type' => new StringType())), 'DateType' => new GenericProperty(array('type' => new DateType())), 'BooleanType' => new GenericProperty(array('type' => new BooleanType())), 'ArrayType' => new GenericProperty(array('type' => new ArrayType()))))); $this->context->setValue('Namespaced::Number', 2); $this->tree = new Tree(new Truth($this->context)); $this->tree->setSegmentId(1); $this->tree->setSegmentName('Segment #1'); $childArray = array(); for ($i = 1; $i <= 3; ++$i) { if ($i !== 3) { $properties = new ArrayIterator(array('configValue' => $i)); $condition = new Equals($this->context, 'Namespaced::Number', $properties); $segment = new Tree($condition); $segment->setSegmentId($i + 1); $segment->setSegmentName('Segment #' . ($i + 1)); } else { $segment = new Tree(new Truth($this->context)); $segment->setSegmentId(4); $segment->setSegmentName('Default'); } $childArray[] = $segment; } $this->tree->setChildren($childArray); }
/** * Test our none composite driver * @return void */ public function testNone() { $this->context->setValue('Namespaced::Property', '1'); $properties1 = new ArrayIterator(array('configValue' => '2')); $equals1 = new Equals($this->context, 'Namespaced::Property', $properties1); $properties2 = new ArrayIterator(array('configValue' => '2')); $equals2 = new Equals($this->context, 'Namespaced::Property', $properties2); $properties3 = new ArrayIterator(array('configValue' => '3')); $equals3 = new Equals($this->context, 'Namespaced::Property', $properties3); $allParams = new ArrayIterator(array($equals1, $equals2, $equals3)); $all = new None($allParams); $this->assertEquals($all->evaluate(), true); $properties1['configValue'] = '1'; $this->assertEquals($all->evaluate(), false); }
/** * Test our stringNotContains driver * @return void */ public function testStringNotContains() { $this->context->setValue('Namespaced::Property', 'somestring'); $properties = new ArrayIterator(array('configValue' => 'nada')); $stringNotContains = new StringNotContains($this->context, 'Namespaced::Property', $properties); $this->assertEquals($stringNotContains->evaluate(), true); $properties['configValue'] = 'g'; $this->assertEquals($stringNotContains->evaluate(), false); $properties['configValue'] = 'om'; $this->assertEquals($stringNotContains->evaluate(), false); }