evaluate(); $this->assertIsA($result, 'core_kernel_classes_Literal'); $this->assertEquals($result->literal, '17'); //5 - 12 $operation = core_kernel_rules_OperationFactory::createOperation( $constant5, $constant12, new core_kernel_classes_Resource(RulesRdf::INSTANCE_OPERATOR_MINUS) ); $result = $operation->evaluate(); $this->assertIsA($result, 'core_kernel_classes_Literal'); $this->assertEquals($result->literal, '-7'); //5 * 12 $operation = core_kernel_rules_OperationFactory::createOperation( $constant5, $constant12, new core_kernel_classes_Resource(RulesRdf::INSTANCE_OPERATOR_MULTIPLY) ); $result = $operation->evaluate(); $this->assertIsA($result, 'core_kernel_classes_Literal'); $this->assertEquals($result->literal, '60'); //60 / 12 $constant60 = core_kernel_rules_TermFactory::createConst('60'); $operation = core_kernel_rules_OperationFactory::createOperation( $constant60, $constant12, new core_kernel_classes_Resource(RulesRdf::INSTANCE_OPERATOR_DIVISION) ); $result = $operation->evaluate(); $this->assertIsA($result, 'core_kernel_classes_Literal'); $this->assertEquals($result->literal, '5'); // 60 concat 12 $operation = core_kernel_rules_OperationFactory::createOperation( $constant60, $constant12, new core_kernel_classes_Resource(RulesRdf::INSTANCE_OPERATOR_CONCAT) ); $result = $operation->evaluate(); $this->assertIsA($result, 'core_kernel_classes_Literal'); $this->assertEquals($result->literal, '60 12'); // raise excption bad operator $operation = core_kernel_rules_OperationFactory::createOperation( $constant60, $constant12, new core_kernel_classes_Resource(RulesRdf::INSTANCE_OPERATOR_UNION) ); try { $operation->evaluate(); $this->fail('should raise exception : problem evaluating operation, operator do not match with operands'); } catch (common_Exception $e) { $this->assertEquals($e->getMessage(), 'problem evaluating operation, operator do not match with operands'); } $constant60->delete(); $constant5->delete(); $constant12->delete(); $operation->delete(); } }