Jeroen De Dauw has uploaded a new change for review.
https://gerrit.wikimedia.org/r/64064
Change subject: SomePropertyDescription now takes anything that is a DataValue
as $propertyId argument
......................................................................
SomePropertyDescription now takes anything that is a DataValue as $propertyId
argument
Change-Id: I11e41c6777885ad4f6ec3a6f6c3d8decf4728ada
---
M Tests/Phpunit/Language/Description/SomePropertyTest.php
M includes/Ask/Language/Description/SomeProperty.php
2 files changed, 23 insertions(+), 20 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Ask
refs/changes/64/64064/1
diff --git a/Tests/Phpunit/Language/Description/SomePropertyTest.php
b/Tests/Phpunit/Language/Description/SomePropertyTest.php
index ca8e638..eabbe4f 100644
--- a/Tests/Phpunit/Language/Description/SomePropertyTest.php
+++ b/Tests/Phpunit/Language/Description/SomePropertyTest.php
@@ -2,8 +2,10 @@
namespace Ask\Tests\Phpunit\Language\Description;
+use Ask\Language\Description\AnyValue;
+use Ask\Language\Description\Conjunction;
use Ask\Language\Description\SomeProperty;
-use DataValues\PropertyValue;
+use DataValues\StringValue;
/**
* @covers Ask\Language\Description\SomeProperty
@@ -42,10 +44,10 @@
protected function getInstances() {
$instances = array();
- $instances[] = new SomeProperty( new PropertyValue( '_geo' ),
new \Ask\Language\Description\AnyValue() );
- $instances[] = new SomeProperty( new PropertyValue( 'p42' ),
new \Ask\Language\Description\Conjunction( array() ) );
- $instances[] = new SomeProperty( new PropertyValue( 'foo' ),
new \Ask\Language\Description\AnyValue(), true );
- $instances[] = new SomeProperty( new PropertyValue(
'~=[,,_,,]:3' ), new \Ask\Language\Description\AnyValue(), false );
+ $instances[] = new SomeProperty( new StringValue( '_geo' ), new
AnyValue() );
+ $instances[] = new SomeProperty( new StringValue( 'p42' ), new
Conjunction( array() ) );
+ $instances[] = new SomeProperty( new StringValue( 'foo' ), new
AnyValue(), true );
+ $instances[] = new SomeProperty( new StringValue( '~=[,,_,,]:3'
), new AnyValue(), false );
return $instances;
}
@@ -62,7 +64,7 @@
$this->assertInstanceOf(
'Ask\Language\Description\Description', $subDescription );
- $newInstance = new SomeProperty( $description->getProperty(),
$subDescription );
+ $newInstance = new SomeProperty( $description->getPropertyId(),
$subDescription );
$this->assertEquals(
$subDescription,
@@ -79,15 +81,15 @@
* @param SomeProperty $description
*/
public function testGetProperty( SomeProperty $description ) {
- $property = $description->getProperty();
+ $property = $description->getPropertyId();
- $this->assertInstanceOf( '\DataValues\PropertyValue', $property
);
+ $this->assertInstanceOf( '\DataValues\DataValue', $property );
$newInstance = new SomeProperty( $property,
$description->getSubDescription() );
$this->assertEquals(
$property,
- $newInstance->getProperty(),
+ $newInstance->getPropertyId(),
'Property is returned as it was passed to the
constructor'
);
}
@@ -104,7 +106,7 @@
$this->assertInternalType( 'boolean', $isSubProperty );
- $newInstance = new SomeProperty( $description->getProperty(),
$description->getSubDescription(), $isSubProperty );
+ $newInstance = new SomeProperty( $description->getPropertyId(),
$description->getSubDescription(), $isSubProperty );
$this->assertEquals(
$isSubProperty,
diff --git a/includes/Ask/Language/Description/SomeProperty.php
b/includes/Ask/Language/Description/SomeProperty.php
index dd27193..5f88360 100644
--- a/includes/Ask/Language/Description/SomeProperty.php
+++ b/includes/Ask/Language/Description/SomeProperty.php
@@ -2,6 +2,7 @@
namespace Ask\Language\Description;
+use DataValues\DataValue;
use DataValues\PropertyValue;
use InvalidArgumentException;
@@ -47,7 +48,7 @@
*
* @var PropertyValue
*/
- private $property;
+ private $propertyId;
/**
* The description the properties value should match.
@@ -86,14 +87,14 @@
*
* @since 0.1
*
- * @param PropertyValue $property
+ * @param DataValue $propertyId
* @param Description $subDescription
* @param boolean $isSubProperty
*
* @throws InvalidArgumentException
*/
- public function __construct( PropertyValue $property, Description
$subDescription, $isSubProperty = false ) {
- $this->property = $property;
+ public function __construct( DataValue $propertyId, Description
$subDescription, $isSubProperty = false ) {
+ $this->propertyId = $propertyId;
$this->subDescription = $subDescription;
if ( !is_bool( $isSubProperty ) ) {
@@ -119,10 +120,10 @@
*
* @since 0.1
*
- * @return PropertyValue
+ * @return DataValue
*/
- public function getProperty() {
- return $this->property;
+ public function getPropertyId() {
+ return $this->propertyId;
}
/**
@@ -178,7 +179,7 @@
*/
public function getArrayValue() {
return array(
- 'property' => $this->property->toArray(),
+ 'property' => $this->propertyId->toArray(),
'description' => $this->subDescription->toArray(),
'issubproperty' => $this->isSubProperty
);
@@ -196,7 +197,7 @@
public function equals( $mixed ) {
return $mixed instanceof SomeProperty
&& $this->isSubProperty === $mixed->isSubProperty()
- && $this->property->equals( $mixed->getProperty() )
+ && $this->propertyId->equals( $mixed->getPropertyId() )
&& $this->subDescription->equals(
$mixed->getSubDescription() );
}
@@ -211,7 +212,7 @@
if ( $this->hash === null ) {
$this->hash = sha1(
$this->getType() .
- $this->property->getHash() .
+ $this->propertyId->getHash() .
$this->subDescription->getHash() .
$this->isSubProperty
);
--
To view, visit https://gerrit.wikimedia.org/r/64064
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I11e41c6777885ad4f6ec3a6f6c3d8decf4728ada
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Ask
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits