コード例 #1
0
 public function descriptionProvider()
 {
     $descriptionFactory = new DescriptionFactory();
     $dataItemFactory = new DataItemFactory();
     #0 No concept
     $concept = false;
     $description = $descriptionFactory->newConceptDescription($dataItemFactory->newDIWikiPage('Foo', SMW_NS_CONCEPT));
     $expected = new \stdClass();
     $expected->type = 1;
     $expected->joinfield = '';
     $provider[] = array($description, $concept, $expected);
     #1 Cached concept
     $concept = new \stdClass();
     $concept->concept_size = 1;
     $concept->concept_features = 1;
     $concept->concept_depth = 1;
     $concept->cache_date = strtotime("now");
     $description = $descriptionFactory->newConceptDescription($dataItemFactory->newDIWikiPage('Foo', SMW_NS_CONCEPT));
     $expected = new \stdClass();
     $expected->type = 1;
     $expected->joinfield = 't0.s_id';
     $expected->where = 't0.o_id=42';
     $expected->queryNumber = 0;
     $provider[] = array($description, $concept, $expected);
     #2 Non cached concept
     $concept = new \stdClass();
     $concept->concept_txt = "[[Category:Foo]]";
     $concept->concept_size = 1;
     $concept->concept_features = 1;
     $concept->concept_depth = 1;
     $concept->cache_date = false;
     $description = $descriptionFactory->newConceptDescription($dataItemFactory->newDIWikiPage('Foo', SMW_NS_CONCEPT));
     $expected = new \stdClass();
     $expected->type = 1;
     $expected->joinfield = 't1.s_id';
     $expected->components = array(2 => 't1.o_id');
     $expected->queryNumber = 1;
     $provider[] = array($description, $concept, $expected);
     return $provider;
 }
コード例 #2
0
 public function descriptionProvider()
 {
     $descriptionFactory = new DescriptionFactory();
     $dataItemFactory = new DataItemFactory();
     #0
     $pageId = 42;
     $description = $descriptionFactory->newClassDescription($dataItemFactory->newDIWikiPage('Foo', NS_CATEGORY));
     $expected = new \stdClass();
     $expected->type = 1;
     $expected->components = array(1 => "t0.o_id");
     $expected->joinfield = "t0.s_id";
     $provider[] = array($description, $pageId, $expected);
     #1 Empty
     $pageId = 0;
     $description = $descriptionFactory->newClassDescription($dataItemFactory->newDIWikiPage('Foo', NS_CATEGORY));
     $expected = new \stdClass();
     $expected->type = 2;
     $expected->components = array();
     $expected->joinfield = "";
     $provider[] = array($description, $pageId, $expected);
     return $provider;
 }
コード例 #3
0
 public function descriptionProvider()
 {
     $descriptionFactory = new DescriptionFactory();
     $dataItemFactory = new DataItemFactory();
     #0 SMW_CMP_EQ
     $description = $descriptionFactory->newValueDescription($dataItemFactory->newDIWikiPage('Foo', NS_MAIN), null, SMW_CMP_EQ);
     $expected = new \stdClass();
     $expected->type = 2;
     $expected->alias = "t0";
     $expected->joinfield = array(42);
     $provider[] = array($description, $expected);
     #1 SMW_CMP_LEQ
     $description = $descriptionFactory->newValueDescription($dataItemFactory->newDIWikiPage('Foo', NS_MAIN), null, SMW_CMP_LEQ);
     $expected = new \stdClass();
     $expected->type = 1;
     $expected->alias = "t0";
     $expected->joinfield = "t0.smw_id";
     $expected->where = "t0.smw_sortkey<=Foo";
     $provider[] = array($description, $expected);
     #2 SMW_CMP_LIKE
     $description = $descriptionFactory->newValueDescription($dataItemFactory->newDIWikiPage('Foo', NS_MAIN), null, SMW_CMP_LIKE);
     $expected = new \stdClass();
     $expected->type = 1;
     $expected->alias = "t0";
     $expected->joinfield = "t0.smw_id";
     $expected->where = "t0.smw_sortkey LIKE Foo";
     $provider[] = array($description, $expected);
     #3 not a DIWikiPage
     $description = $descriptionFactory->newValueDescription($dataItemFactory->newDIBLob('Foo'));
     $expected = new \stdClass();
     $expected->type = 1;
     $expected->joinfield = "";
     $expected->where = "";
     $provider[] = array($description, $expected);
     return $provider;
 }
コード例 #4
0
 public function testCanConstructDITime()
 {
     $instance = new DataItemFactory();
     $this->assertInstanceOf(DITime::class, $instance->newDITime(1, '1900'));
 }
コード例 #5
0
 public function propertyValueProvider()
 {
     $dataItemFactory = new DataItemFactory();
     $provider[] = array($dataItemFactory->newDIProperty('Foo'), PropertyValueFormatter::VALUE, null, 'Foo');
     $provider[] = array($dataItemFactory->newDIProperty('Foo'), PropertyValueFormatter::WIKI_SHORT, null, 'Foo');
     $provider[] = array($dataItemFactory->newDIProperty('Foo'), PropertyValueFormatter::HTML_SHORT, null, 'Foo');
     $provider[] = array($dataItemFactory->newDIProperty('Foo'), PropertyValueFormatter::WIKI_LONG, null, 'Property:Foo');
     $provider[] = array($dataItemFactory->newDIProperty('Foo'), PropertyValueFormatter::HTML_LONG, null, 'Property:Foo');
     return $provider;
 }
コード例 #6
0
 public function valueProvider()
 {
     $dataItemFactory = new DataItemFactory();
     $properties = array($dataItemFactory->newDIProperty('Foo'), $dataItemFactory->newDIProperty('Bar'), 'InvalidFieldPropertyNotSet');
     $provider[] = array($properties, "Title without special characters;2001", array('description' => "[[Foo::Title without special characters]] [[Bar::2001]]", 'wikivalue' => "Title without special characters; 2001"));
     $provider[] = array($properties, "Title with \$&%'* special characters;(..&^%..)", array('description' => "[[Foo::Title with \$&%'* special characters]] [[Bar::(..&^%..)]]", 'wikivalue' => "Title with \$&%'* special characters; (..&^%..)"));
     $provider[] = array($properties, " Title with space before ; After the divider ", array('description' => "[[Foo::Title with space before]] [[Bar::After the divider]]", 'wikivalue' => "Title with space before; After the divider"));
     $provider[] = array($properties, " Title with backslash\\; escape ; After the divider ", array('description' => "[[Foo::Title with backslash; escape]] [[Bar::After the divider]]", 'wikivalue' => "Title with backslash\\; escape; After the divider"));
     return $provider;
 }
コード例 #7
0
 public function descriptionProvider()
 {
     $descriptionFactory = new DescriptionFactory();
     $dataItemFactory = new DataItemFactory();
     #0 Blob + wildcard
     $isFixedPropertyTable = false;
     $indexField = '';
     $sortKeys = array();
     $property = $dataItemFactory->newDIProperty('Foo');
     $property->setPropertyTypeId('_txt');
     $description = $descriptionFactory->newSomeProperty($property, $descriptionFactory->newThingDescription());
     $expected = new \stdClass();
     $expected->type = 1;
     $expected->joinTable = 'FooPropTable';
     $expected->components = array(1 => "t0.p_id");
     $expected->sortfields = array();
     $provider[] = array($description, $isFixedPropertyTable, $indexField, $sortKeys, $expected);
     #1 WikiPage + SMW_CMP_EQ
     $isFixedPropertyTable = false;
     $indexField = 'wikipageIndex';
     $sortKeys = array();
     $property = $dataItemFactory->newDIProperty('Foo');
     $property->setPropertyTypeId('_wpg');
     $description = $descriptionFactory->newSomeProperty($property, $descriptionFactory->newValueDescription($dataItemFactory->newDIWikiPage('Bar', NS_MAIN), null, SMW_CMP_EQ));
     $expected = new \stdClass();
     $expected->type = 1;
     $expected->joinTable = 'FooPropTable';
     $expected->components = array(1 => "t0.p_id", 2 => "t0.wikipageIndex");
     $expected->queryNumber = 0;
     $expected->where = '';
     $expected->sortfields = array();
     $provider[] = array($description, $isFixedPropertyTable, $indexField, $sortKeys, $expected);
     #2 WikiPage + SMW_CMP_EQ + sort
     $isFixedPropertyTable = false;
     $indexField = 'wikipageIndex';
     $sortKeys = array('Foo' => 'DESC');
     $property = $dataItemFactory->newDIProperty('Foo');
     $property->setPropertyTypeId('_wpg');
     $description = $descriptionFactory->newSomeProperty($property, $descriptionFactory->newValueDescription($dataItemFactory->newDIWikiPage('Bar', NS_MAIN), null, SMW_CMP_EQ));
     $expected = new \stdClass();
     $expected->type = 1;
     $expected->joinTable = 'FooPropTable';
     $expected->components = array(1 => "t0.p_id", 2 => "t0.wikipageIndex");
     $expected->queryNumber = 0;
     $expected->where = '';
     $expected->sortfields = array('Foo' => 'idst0.smw_sortkey');
     $expected->from = ' INNER JOIN  AS idst0 ON idst0.smw_id=t0.wikipageIndex';
     $provider[] = array($description, $isFixedPropertyTable, $indexField, $sortKeys, $expected);
     #3 Blob + SMW_CMP_EQ
     $isFixedPropertyTable = false;
     $indexField = 'blobIndex';
     $sortKeys = array();
     $property = $dataItemFactory->newDIProperty('Foo');
     $property->setPropertyTypeId('_txt');
     $description = $descriptionFactory->newSomeProperty($property, $descriptionFactory->newValueDescription($dataItemFactory->newDIBlob('Bar'), null, SMW_CMP_EQ));
     $expected = new \stdClass();
     $expected->type = 1;
     $expected->joinTable = 'FooPropTable';
     $expected->components = array(1 => "t0.p_id");
     $expected->queryNumber = 0;
     $expected->where = '(t0.blobIndex=fixedFooWhereCond)';
     $expected->sortfields = array();
     $provider[] = array($description, $isFixedPropertyTable, $indexField, $sortKeys, $expected);
     #4 Blob + SMW_CMP_EQ + sort
     $isFixedPropertyTable = false;
     $indexField = 'blobIndex';
     $sortKeys = array('Foo' => 'ASC');
     $property = $dataItemFactory->newDIProperty('Foo');
     $property->setPropertyTypeId('_txt');
     $description = $descriptionFactory->newSomeProperty($property, $descriptionFactory->newValueDescription($dataItemFactory->newDIBlob('Bar'), null, SMW_CMP_EQ));
     $expected = new \stdClass();
     $expected->type = 1;
     $expected->joinTable = 'FooPropTable';
     $expected->components = array(1 => "t0.p_id");
     $expected->queryNumber = 0;
     $expected->where = '(t0.blobIndex=fixedFooWhereCond)';
     $expected->sortfields = array('Foo' => 't0.blobIndex');
     $expected->from = '';
     $provider[] = array($description, $isFixedPropertyTable, $indexField, $sortKeys, $expected);
     #5 Check SemanticMaps compatibility mode (invokes `getSQLCondition`)
     $isFixedPropertyTable = false;
     $indexField = 'blobIndex';
     $sortKeys = array();
     $property = $dataItemFactory->newDIProperty('Foo');
     $property->setPropertyTypeId('_txt');
     $valueDescription = $this->getMockBuilder('\\SMW\\Query\\Language\\ValueDescription')->disableOriginalConstructor()->setMethods(array('getSQLCondition', 'getDataItem'))->getMock();
     $valueDescription->expects($this->any())->method('getProperty')->will($this->returnValue($property));
     $valueDescription->expects($this->any())->method('getDataItem')->will($this->returnValue($dataItemFactory->newDIBlob('13,56')));
     $valueDescription->expects($this->once())->method('getSQLCondition')->will($this->returnValue('foo AND bar'));
     $description = $descriptionFactory->newSomeProperty($property, $valueDescription);
     $expected = new \stdClass();
     $expected->type = 1;
     $expected->joinTable = 'FooPropTable';
     $expected->components = array(1 => "t0.p_id");
     $expected->queryNumber = 0;
     $expected->where = '(foo AND bar)';
     $expected->sortfields = array();
     $expected->from = '';
     $provider[] = array($description, $isFixedPropertyTable, $indexField, $sortKeys, $expected);
     #6, see 556
     $isFixedPropertyTable = false;
     $indexField = '';
     $sortKeys = array();
     $property = $dataItemFactory->newDIProperty('Foo');
     $property->setPropertyTypeId('_txt');
     $description = $descriptionFactory->newSomeProperty($property, $descriptionFactory->newDisjunction(array($descriptionFactory->newValueDescription($dataItemFactory->newDIBlob('Bar')), $descriptionFactory->newValueDescription($dataItemFactory->newDIBlob('Baz')))));
     $expected = new \stdClass();
     $expected->type = 1;
     $expected->joinTable = 'FooPropTable';
     $expected->components = array(1 => "t0.p_id");
     $expected->queryNumber = 0;
     $expected->where = '((t0.=fixedFooWhereCond) OR (t0.=fixedFooWhereCond))';
     $expected->sortfields = array();
     $expected->from = '';
     $provider[] = array($description, $isFixedPropertyTable, $indexField, $sortKeys, $expected);
     return $provider;
 }