/** * Test common_Collection->intersect */ public function testIntersect() { $collection = new common_Collection(new common_Object('__METHOD__')); $collection->add(new core_kernel_classes_Literal('plop')); $collection->add(new core_kernel_classes_Literal('plop2')); $collection->add($this->toto); $collection->add($this->tata); $results = $collection->intersect($this->object); $this->assertIsA($results, 'common_Collection'); $this->assertTrue($results->count() == 2); $this->assertTrue($results->get($results->indexOf($this->toto))->literal == 'toto'); $this->assertTrue($results->get($results->indexOf($this->tata))->literal == 'tata'); }
/** * Short description of method evalutateSetOperation * * @access public * @author firstname and lastname of author, <*****@*****.**> * @param Resource $setOperator * @param Collection $actualSet * @param ContainerCollection $newSet * @return core_kernel_classes_ContainerCollection */ public function evalutateSetOperation(core_kernel_classes_Resource $setOperator, common_Collection $actualSet, core_kernel_classes_ContainerCollection $newSet) { $returnValue = null; if ($setOperator->getUri() == INSTANCE_OPERATOR_UNION) { $returnValue = $actualSet->union($newSet); } else { if ($setOperator->getUri() == INSTANCE_OPERATOR_INTERSECT) { $returnValue = $actualSet->intersect($newSet); } else { throw new common_Exception('unknow set operator'); } } return $returnValue; }