Jeroen De Dauw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/49929


Change subject: Added tests for SortExpression toArray
......................................................................

Added tests for SortExpression toArray

Change-Id: I56650080d65d56f676f40b5cd1e62ae8e3984a54
---
M Ask.mw.php
M includes/Ask/Language/Option/PropertyValueSortExpression.php
M tests/phpunit/Language/Option/PropertyValueSortExpressionTest.php
M tests/phpunit/Language/Option/SortExpressionTest.php
4 files changed, 42 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Ask 
refs/changes/29/49929/1

diff --git a/Ask.mw.php b/Ask.mw.php
index e51946a..582002c 100644
--- a/Ask.mw.php
+++ b/Ask.mw.php
@@ -47,8 +47,8 @@
        $wgAutoloadClasses['Ask\Tests\AskTestCase']
                = __DIR__ . '/tests/phpunit/AskTestCase.php';
 
-       $wgAutoloadClasses['Ask\Tests\Option\SortExpressionTest']
-               = __DIR__ . '/tests/phpunit/Language/Option/SortExpression.php';
+       $wgAutoloadClasses['Ask\Tests\Language\Option\SortExpressionTest']
+               = __DIR__ . 
'/tests/phpunit/Language/Option/SortExpressionTest.php';
 
        
$wgAutoloadClasses['Ask\Tests\Language\Description\DescriptionCollectionTest']
                = __DIR__ . 
'/tests/phpunit/Language/Description/DescriptionCollectionTest.php';
@@ -79,6 +79,8 @@
                'Language/Description/Disjunction',
                'Language/Description/ValueDescription',
 
+               'Language/Option/PropertyValueSortExpression',
+
                'Language/Selection/PropertySelection',
                'Language/Selection/SubjectSelection',
 
diff --git a/includes/Ask/Language/Option/PropertyValueSortExpression.php 
b/includes/Ask/Language/Option/PropertyValueSortExpression.php
index 1250655..c193bfa 100644
--- a/includes/Ask/Language/Option/PropertyValueSortExpression.php
+++ b/includes/Ask/Language/Option/PropertyValueSortExpression.php
@@ -55,7 +55,7 @@
        public function __construct( PropertyValue $property, $direction ) {
                $this->property = $property;
 
-               if ( !is_string( $this->direction ) ) {
+               if ( !is_string( $direction ) ) {
                        throw new InvalidArgumentException( '$direction needs 
to be one of the direction constants' );
                }
 
diff --git a/tests/phpunit/Language/Option/PropertyValueSortExpressionTest.php 
b/tests/phpunit/Language/Option/PropertyValueSortExpressionTest.php
index f0a7225..e9dd157 100644
--- a/tests/phpunit/Language/Option/PropertyValueSortExpressionTest.php
+++ b/tests/phpunit/Language/Option/PropertyValueSortExpressionTest.php
@@ -35,6 +35,27 @@
  */
 class PropertyValueSortExpressionTest extends SortExpressionTest {
 
+       /**
+        * @see SortExpressionTest::getInstances
+        *
+        * @since 0.1
+        *
+        * @return SortExpression[]
+        */
+       protected function getInstances() {
+               $instances = array();
 
+               $instances[] = new 
\Ask\Language\Option\PropertyValueSortExpression(
+                       new \DataValues\PropertyValue( 'foo' ),
+                       SortExpression::ASCENDING
+               );
+
+               $instances[] = new 
\Ask\Language\Option\PropertyValueSortExpression(
+                       new \DataValues\PropertyValue( 'foo' ),
+                       SortExpression::DESCENDING
+               );
+
+               return $instances;
+       }
 
 }
diff --git a/tests/phpunit/Language/Option/SortExpressionTest.php 
b/tests/phpunit/Language/Option/SortExpressionTest.php
index 49616d8..78ecc89 100644
--- a/tests/phpunit/Language/Option/SortExpressionTest.php
+++ b/tests/phpunit/Language/Option/SortExpressionTest.php
@@ -33,6 +33,22 @@
 abstract class SortExpressionTest extends \Ask\Tests\AskTestCase {
 
        /**
+        * @since 0.1
+        *
+        * @return SortExpression[]
+        */
+       protected abstract function getInstances();
+
+       /**
+        * @since 0.1
+        *
+        * @return SortExpression[][]
+        */
+       public function instanceProvider() {
+               return $this->arrayWrap( $this->getInstances() );
+       }
+
+       /**
         * @dataProvider instanceProvider
         *
         * @since 0.1

-- 
To view, visit https://gerrit.wikimedia.org/r/49929
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I56650080d65d56f676f40b5cd1e62ae8e3984a54
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

Reply via email to