jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/347135 )

Change subject: objectcache: Complete code coverage for CachedBagOStuff
......................................................................


objectcache: Complete code coverage for CachedBagOStuff

Change-Id: I8a228d68701f1ad4d37f60de53d105c32898dc8b
---
M includes/libs/objectcache/CachedBagOStuff.php
M tests/phpunit/includes/libs/objectcache/CachedBagOStuffTest.php
2 files changed, 57 insertions(+), 20 deletions(-)

Approvals:
  Aaron Schulz: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/libs/objectcache/CachedBagOStuff.php 
b/includes/libs/objectcache/CachedBagOStuff.php
index 496a4e8..c85a82e 100644
--- a/includes/libs/objectcache/CachedBagOStuff.php
+++ b/includes/libs/objectcache/CachedBagOStuff.php
@@ -81,29 +81,9 @@
                $this->backend->setDebug( $bool );
        }
 
-       public function lock( $key, $timeout = 6, $expiry = 6, $rclass = '' ) {
-               return $this->backend->lock( $key, $timeout, $expiry, $rclass );
-       }
-
-       public function unlock( $key ) {
-               return $this->backend->unlock( $key );
-       }
-
        public function deleteObjectsExpiringBefore( $date, $progressCallback = 
false ) {
                parent::deleteObjectsExpiringBefore( $date, $progressCallback );
                return $this->backend->deleteObjectsExpiringBefore( $date, 
$progressCallback );
-       }
-
-       public function getLastError() {
-               return $this->backend->getLastError();
-       }
-
-       public function clearLastError() {
-               $this->backend->clearLastError();
-       }
-
-       public function modifySimpleRelayEvent( array $event ) {
-               return $this->backend->modifySimpleRelayEvent( $event );
        }
 
        public function makeKey() {
@@ -114,4 +94,28 @@
                return call_user_func_array( [ $this->backend, __FUNCTION__ ], 
func_get_args() );
        }
 
+       // These just call the backend (tested elsewhere)
+       // @codeCoverageIgnoreStart
+
+       public function lock( $key, $timeout = 6, $expiry = 6, $rclass = '' ) {
+               return $this->backend->lock( $key, $timeout, $expiry, $rclass );
+       }
+
+       public function unlock( $key ) {
+               return $this->backend->unlock( $key );
+       }
+
+       public function getLastError() {
+               return $this->backend->getLastError();
+       }
+
+       public function clearLastError() {
+               return $this->backend->clearLastError();
+       }
+
+       public function modifySimpleRelayEvent( array $event ) {
+               return $this->backend->modifySimpleRelayEvent( $event );
+       }
+
+       // @codeCoverageIgnoreEnd
 }
diff --git a/tests/phpunit/includes/libs/objectcache/CachedBagOStuffTest.php 
b/tests/phpunit/includes/libs/objectcache/CachedBagOStuffTest.php
index 7b9d6d5..5fbbdec 100644
--- a/tests/phpunit/includes/libs/objectcache/CachedBagOStuffTest.php
+++ b/tests/phpunit/includes/libs/objectcache/CachedBagOStuffTest.php
@@ -84,6 +84,39 @@
        }
 
        /**
+        * @covers CachedBagOStuff::setDebug
+        */
+       public function testSetDebug() {
+               $backend = new HashBagOStuff();
+               $cache = new CachedBagOStuff( $backend );
+               // Access private property 'debugMode'
+               $backend = TestingAccessWrapper::newFromObject( $backend );
+               $cache = TestingAccessWrapper::newFromObject( $cache );
+               $this->assertFalse( $backend->debugMode );
+               $this->assertFalse( $cache->debugMode );
+
+               $cache->setDebug( true );
+               // Should have set both
+               $this->assertTrue( $backend->debugMode, 'sets backend' );
+               $this->assertTrue( $cache->debugMode, 'sets self' );
+       }
+
+       /**
+        * @covers CachedBagOStuff::deleteObjectsExpiringBefore
+        */
+       public function testExpire() {
+               $backend = $this->getMockBuilder( HashBagOStuff::class )
+                       ->setMethods( [ 'deleteObjectsExpiringBefore' ] )
+                       ->getMock();
+               $backend->expects( $this->once() )
+                       ->method( 'deleteObjectsExpiringBefore' )
+                       ->willReturn( false );
+
+               $cache = new CachedBagOStuff( $backend );
+               $cache->deleteObjectsExpiringBefore( '20110401000000' );
+       }
+
+       /**
         * @covers CachedBagOStuff::makeKey
         */
        public function testMakeKey() {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I8a228d68701f1ad4d37f60de53d105c32898dc8b
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to