[MediaWiki-commits] [Gerrit] mediawiki...ActiveAbstract[wmf/1.31.0-wmf.15]: Revert "Move classes to own files"

2018-01-04 Thread Chad (Code Review)
Chad has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/402062 )

Change subject: Revert "Move classes to own files"
..


Revert "Move classes to own files"

This reverts commit 506e58f5f05571cf2ae6acaf76204a63775fd3c6.

Bug: T184177
Change-Id: I3dd113313c1d1711636693b1b952b49996e4f518
---
M .phpcs.xml
M AbstractFilter.php
M GoogleCoopFilter.php
D NoredirectFilter.php
M extension.json
M tests/phpunit/AbstractFilterTest.php
D tests/phpunit/DroppingReturnValueMap.php
R tests/phpunit/backup_AbstractTest.php
8 files changed, 105 insertions(+), 111 deletions(-)

Approvals:
  Chad: Verified; Looks good to me, approved



diff --git a/.phpcs.xml b/.phpcs.xml
index e382191..eca824a 100644
--- a/.phpcs.xml
+++ b/.phpcs.xml
@@ -2,6 +2,8 @@
 


+   
+   



diff --git a/AbstractFilter.php b/AbstractFilter.php
index 2d00c76..4fe3b11 100644
--- a/AbstractFilter.php
+++ b/AbstractFilter.php
@@ -297,3 +297,13 @@
$this->revision = $rev;
}
 }
+
+class NoredirectFilter extends DumpFilter {
+   /**
+* @param stdClass $page
+* @return bool
+*/
+   function pass( $page ) {
+   return !$page->page_is_redirect;
+   }
+}
diff --git a/GoogleCoopFilter.php b/GoogleCoopFilter.php
index 418d355..e55a0c1 100644
--- a/GoogleCoopFilter.php
+++ b/GoogleCoopFilter.php
@@ -1,4 +1,5 @@
 page_is_redirect;
-   }
-}
diff --git a/extension.json b/extension.json
index 4383ff3..95861eb 100644
--- a/extension.json
+++ b/extension.json
@@ -15,11 +15,5 @@
"i18n"
]
},
-   "AutoloadClasses": {
-   "AbstractFilter": "AbstractFilter.php",
-   "DroppingReturnValueMap": 
"tests/phpunit/DroppingReturnValueMap.php",
-   "NoredirectFilter": "NoredirectFilter.php",
-   "GoogleCoopFilter": "GoogleCoopFilter.php"
-   },
"manifest_version": 1
 }
diff --git a/tests/phpunit/AbstractFilterTest.php 
b/tests/phpunit/AbstractFilterTest.php
index d9b3f59..3698016 100644
--- a/tests/phpunit/AbstractFilterTest.php
+++ b/tests/phpunit/AbstractFilterTest.php
@@ -1,4 +1,95 @@
 expects( $this->once() )
+ *   ->method( 'methodName' )
+ *   ->parameters( $this->equalTo( param1 ), $this->equalTo( param2 ) )
+ *   ->will( $this->returnValue( ret12 ) );
+ *   mock->expects( $this->once() )
+ *   ->method( 'methodName' )
+ *   ->parameters( $this->equalTo( param3 ), $this->equalTo( param4 ) )
+ *   ->will( $this->returnValue( ret34 ) );
+ *
+ * (the above code ignore the first of the two statements) to do what it is
+ * supposed to do (i.e.: asserting that methodName is called exactly two times.
+ * Once with parameters param1, param2 returning ret12, and once with
+ * parameters param3, param4 returning ret34 (which of the two happens first
+ * does not matter), you can use the following code:
+ *
+ *   $map = array(
+ * array( param1, param2, ret12),
+ * array( param3, param4, ret34)
+ *   );
+ *   mock->expects( $this->exactly( count( $map ) ) )
+ *   ->method( 'methodName' )
+ *   ->will( new DroppingReturnValueMap( $map ) );
+ *
+ * This code asserts that each parameter given in $map is used exactly once,
+ * while each call returns the given return value.
+ *
+ *
+ * The implementation of DroppingReturnValueMap is based off of
+ * PHPUnit_Framework_MockObject_Stub_ReturnValueMap from PHPUnit_MockObject by
+ * Sebastian Bergmann (under the 3-clause-BSD licence).
+ */
+class DroppingReturnValueMap implements PHPUnit_Framework_MockObject_Stub {
+   protected $valueMap;
+
+   public function __construct( array $valueMap ) {
+   $this->valueMap = $valueMap;
+   }
+
+   public function invoke( PHPUnit_Framework_MockObject_Invocation 
$invocation ) {
+   $parameterCount = count( $invocation->parameters );
+
+   foreach ( $this->valueMap as $key => $map ) {
+   if ( !is_array( $map ) || $parameterCount != count( 
$map ) - 1 ) {
+   continue;
+   }
+
+   $return = array_pop( $map );
+   if ( $invocation->parameters === $map ) {
+   unset( $this->valueMap[$key] );
+
+   return $return;
+   }
+   }
+
+   // Could not find the actual parameters in valueMap. We signal 
failure, after
+   // formatting the actual parameters in $actual, to have a nice 
error message
+   $actual = "(";
+   $connective = "";
+   foreach ( $invocation->parameters as $parameter ) {
+   $actual .= $connective . " ";
+   try {
+   $actual 

[MediaWiki-commits] [Gerrit] mediawiki...ActiveAbstract[wmf/1.31.0-wmf.15]: Revert "Move classes to own files"

2018-01-04 Thread Chad (Code Review)
Chad has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402062 )

Change subject: Revert "Move classes to own files"
..

Revert "Move classes to own files"

This reverts commit 506e58f5f05571cf2ae6acaf76204a63775fd3c6.

Change-Id: I3dd113313c1d1711636693b1b952b49996e4f518
---
M .phpcs.xml
M AbstractFilter.php
M GoogleCoopFilter.php
D NoredirectFilter.php
M extension.json
M tests/phpunit/AbstractFilterTest.php
D tests/phpunit/DroppingReturnValueMap.php
R tests/phpunit/backup_AbstractTest.php
8 files changed, 105 insertions(+), 111 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ActiveAbstract 
refs/changes/62/402062/1

diff --git a/.phpcs.xml b/.phpcs.xml
index e382191..eca824a 100644
--- a/.phpcs.xml
+++ b/.phpcs.xml
@@ -2,6 +2,8 @@
 


+   
+   



diff --git a/AbstractFilter.php b/AbstractFilter.php
index 2d00c76..4fe3b11 100644
--- a/AbstractFilter.php
+++ b/AbstractFilter.php
@@ -297,3 +297,13 @@
$this->revision = $rev;
}
 }
+
+class NoredirectFilter extends DumpFilter {
+   /**
+* @param stdClass $page
+* @return bool
+*/
+   function pass( $page ) {
+   return !$page->page_is_redirect;
+   }
+}
diff --git a/GoogleCoopFilter.php b/GoogleCoopFilter.php
index 418d355..e55a0c1 100644
--- a/GoogleCoopFilter.php
+++ b/GoogleCoopFilter.php
@@ -1,4 +1,5 @@
 page_is_redirect;
-   }
-}
diff --git a/extension.json b/extension.json
index 4383ff3..95861eb 100644
--- a/extension.json
+++ b/extension.json
@@ -15,11 +15,5 @@
"i18n"
]
},
-   "AutoloadClasses": {
-   "AbstractFilter": "AbstractFilter.php",
-   "DroppingReturnValueMap": 
"tests/phpunit/DroppingReturnValueMap.php",
-   "NoredirectFilter": "NoredirectFilter.php",
-   "GoogleCoopFilter": "GoogleCoopFilter.php"
-   },
"manifest_version": 1
 }
diff --git a/tests/phpunit/AbstractFilterTest.php 
b/tests/phpunit/AbstractFilterTest.php
index d9b3f59..3698016 100644
--- a/tests/phpunit/AbstractFilterTest.php
+++ b/tests/phpunit/AbstractFilterTest.php
@@ -1,4 +1,95 @@
 expects( $this->once() )
+ *   ->method( 'methodName' )
+ *   ->parameters( $this->equalTo( param1 ), $this->equalTo( param2 ) )
+ *   ->will( $this->returnValue( ret12 ) );
+ *   mock->expects( $this->once() )
+ *   ->method( 'methodName' )
+ *   ->parameters( $this->equalTo( param3 ), $this->equalTo( param4 ) )
+ *   ->will( $this->returnValue( ret34 ) );
+ *
+ * (the above code ignore the first of the two statements) to do what it is
+ * supposed to do (i.e.: asserting that methodName is called exactly two times.
+ * Once with parameters param1, param2 returning ret12, and once with
+ * parameters param3, param4 returning ret34 (which of the two happens first
+ * does not matter), you can use the following code:
+ *
+ *   $map = array(
+ * array( param1, param2, ret12),
+ * array( param3, param4, ret34)
+ *   );
+ *   mock->expects( $this->exactly( count( $map ) ) )
+ *   ->method( 'methodName' )
+ *   ->will( new DroppingReturnValueMap( $map ) );
+ *
+ * This code asserts that each parameter given in $map is used exactly once,
+ * while each call returns the given return value.
+ *
+ *
+ * The implementation of DroppingReturnValueMap is based off of
+ * PHPUnit_Framework_MockObject_Stub_ReturnValueMap from PHPUnit_MockObject by
+ * Sebastian Bergmann (under the 3-clause-BSD licence).
+ */
+class DroppingReturnValueMap implements PHPUnit_Framework_MockObject_Stub {
+   protected $valueMap;
+
+   public function __construct( array $valueMap ) {
+   $this->valueMap = $valueMap;
+   }
+
+   public function invoke( PHPUnit_Framework_MockObject_Invocation 
$invocation ) {
+   $parameterCount = count( $invocation->parameters );
+
+   foreach ( $this->valueMap as $key => $map ) {
+   if ( !is_array( $map ) || $parameterCount != count( 
$map ) - 1 ) {
+   continue;
+   }
+
+   $return = array_pop( $map );
+   if ( $invocation->parameters === $map ) {
+   unset( $this->valueMap[$key] );
+
+   return $return;
+   }
+   }
+
+   // Could not find the actual parameters in valueMap. We signal 
failure, after
+   // formatting the actual parameters in $actual, to have a nice 
error message
+   $actual = "(";
+   $connective = "";
+   foreach ( $invocation->parameters as $parameter ) {
+   $actual .= $connective . " ";
+   try {
+