getUri()); try { $badTerm->evaluate(); $this->fail('should raise exception : Forbidden type'); } catch (common_Exception $e) { $this->assertEquals($e->getMessage(), 'Forbidden Type of Term'); } // eval const $constantResource = core_kernel_rules_TermFactory::createConst('test1'); $term = $constantResource->evaluate(); $this->assertIsA($term, 'core_kernel_classes_Literal'); $this->assertEquals($term, 'test1'); $constantResource->delete(); //eval SPX $booleanClass = new core_kernel_classes_Class(GenerisRdf::GENERIS_BOOLEAN); $maybe = core_kernel_classes_ResourceFactory::create($booleanClass, 'testCase testCreateSPX', __METHOD__); $SPXResource = core_kernel_rules_TermFactory::createSPX($maybe, new core_kernel_classes_Property(OntologyRdfs::RDFS_COMMENT)); $spxResult = $SPXResource->evaluate(); $this->assertIsA($spxResult, 'core_kernel_classes_Literal'); $this->assertEquals($spxResult, __METHOD__); // eval operation $constant5 = core_kernel_rules_TermFactory::createConst('5'); $constant12 = core_kernel_rules_TermFactory::createConst('12'); $operation = core_kernel_rules_OperationFactory::createOperation( $constant5, $constant12, new core_kernel_classes_Resource(RulesRdf::INSTANCE_OPERATOR_ADD) ); $operationTerm = new core_kernel_rules_Term($operation->getUri()); $result = $operationTerm->evaluate(); $this->assertEquals($result->literal, '17'); $fakeTerm = new core_kernel_rules_Term($maybe->getUri()); try { $fakeTerm->evaluate(); $this->fail('should raise exception : Forbidden type'); } catch (common_Exception $e) { $this->assertEquals($e->getMessage(), 'problem evaluating Term'); } $badTermResource->delete(); $constant5->delete(); $constant12->delete(); $SPXResource->delete(); $operation->delete(); $maybe->delete(); } }