object = new core_kernel_classes_Property(WidgetRdf::PROPERTY_WIDGET); } /** * * @author Lionel Lecaque, lionel@taotesting.com */ public function testGetDomain() { $domainCollection = $this->object->getDomain(); $this->assertTrue($domainCollection instanceof core_kernel_classes_ContainerCollection); $domain = $domainCollection->get(0); $this->assertEquals($domain->getUri(), OntologyRdf::RDF_PROPERTY); $this->assertEquals($domain->getLabel(), 'Property'); $this->assertEquals($domain->getComment(), 'The class of RDF properties.'); } /** * * @author Lionel Lecaque, lionel@taotesting.com */ public function testSetDomain() { $class = new core_kernel_classes_Class(GenerisRdf::GENERIS_BOOLEAN, __METHOD__); $prop = $class->createProperty('test', 'test'); $domain = $prop->getDomain(); $this->assertEquals(1, $domain->count()); $this->assertEquals($class, $domain->get(0)); $widget = new core_kernel_classes_Class(WidgetRdf::CLASS_URI_WIDGET, __METHOD__); $this->assertTrue($prop->setDomain($widget)); $this->assertEquals(2, $prop->getDomain()->count()); $this->assertGreaterThanOrEqual(0, $prop->getDomain()->indexOf($widget)); $this->assertGreaterThanOrEqual(0, $prop->getDomain()->indexOf($class)); //if domain already set return true $this->assertTrue($prop->setDomain($class)); $this->assertEquals(2, $prop->getDomain()->count()); $this->assertGreaterThanOrEqual(0, $prop->getDomain()->indexOf($widget)); $this->assertGreaterThanOrEqual(0, $prop->getDomain()->indexOf($class)); $prop->delete(true); } /** * * @author Lionel Lecaque, lionel@taotesting.com */ public function testGetRange() { $range = $this->object->getRange(); $this->assertTrue($range instanceof core_kernel_classes_Class); $this->assertEquals($range->getUri(), WidgetRdf::CLASS_URI_WIDGET); $this->assertEquals($range->getLabel(), 'Widget Class'); $this->assertEquals($range->getComment(), 'The class of all possible widgets'); } /** * * @author Lionel Lecaque, lionel@taotesting.com */ public function testGetWidget() { $widget = $this->object->getWidget(); $this->assertInstanceOf(core_kernel_classes_Resource::class, $widget); $this->assertEquals($widget->getUri(), 'http://www.tao.lu/datatypes/WidgetDefinitions.rdf#ComboBox'); $this->assertEquals($widget->getLabel(), 'Drop down menu'); $this->assertEquals($widget->getComment(), 'In drop down menu, one may select 1 to N options'); } /** * * @author Lionel Lecaque, lionel@taotesting.com */ public function testSetMultiple() { $class = new core_kernel_classes_Class(GenerisRdf::GENERIS_BOOLEAN, __METHOD__); $prop = $class->createProperty('test', 'test'); $multipleProperty = new core_kernel_classes_Property(GenerisRdf::PROPERTY_MULTIPLE); $this->assertEquals([], $prop->getPropertyValues($multipleProperty)); $prop->setMultiple(true); $this->assertEquals([GenerisRdf::GENERIS_TRUE], $prop->getPropertyValues($multipleProperty)); $prop->delete(true); } /** * * @author Lionel Lecaque, lionel@taotesting.com */ public function testIsMultiple() { $class = new core_kernel_classes_Class(GenerisRdf::GENERIS_BOOLEAN, __METHOD__); $prop = $class->createProperty('test', 'test'); $this->assertFalse($prop->isMultiple()); $prop->setMultiple(true); $this->assertTrue($prop->isMultiple()); $new = new core_kernel_classes_Property($prop->getUri()); $this->assertTrue($new->isMultiple()); $prop->delete(true); } /** * * @author Lionel Lecaque, lionel@taotesting.com */ public function testDelete() { $class = new core_kernel_classes_Class(GenerisRdf::GENERIS_BOOLEAN, __METHOD__); $prop = $class->createProperty('test', 'test'); $instance = $class->createInstance('test', 'test'); $instance->setPropertyValue($prop, GenerisRdf::GENERIS_TRUE); $instance->setPropertyValue($prop, '3'); $this->assertArrayHasKey($prop->getUri(), $class->getProperties()); $val = $instance->getPropertyValues($prop); $this->assertTrue(in_array(GenerisRdf::GENERIS_TRUE, $val)); $this->assertTrue(in_array(3, $val)); $this->assertTrue($prop->delete(true)); $this->assertEquals([], $instance->getPropertyValues($prop)); $this->assertArrayNotHasKey($prop->getUri(), $class->getProperties()); $this->assertTrue($instance->delete()); } }