Merge "objectcache: Complete code coverage for HashBagOStuff"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 1 Apr 2017 02:57:18 +0000 (02:57 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 1 Apr 2017 02:57:18 +0000 (02:57 +0000)
tests/phpunit/includes/libs/objectcache/HashBagOStuffTest.php

index c4db0cf..f44baeb 100644 (file)
@@ -5,6 +5,40 @@
  */
 class HashBagOStuffTest extends PHPUnit_Framework_TestCase {
 
+       /**
+        * @covers HashBagOStuff::__construct
+        */
+       public function testConstruct() {
+               $this->assertInstanceOf(
+                       HashBagOStuff::class,
+                       new HashBagOStuff()
+               );
+       }
+
+       /**
+        * @covers HashBagOStuff::__construct
+        * @expectedException InvalidArgumentException
+        */
+       public function testConstructBadZero() {
+               $cache = new HashBagOStuff( [ 'maxKeys' => 0 ] );
+       }
+
+       /**
+        * @covers HashBagOStuff::__construct
+        * @expectedException InvalidArgumentException
+        */
+       public function testConstructBadNeg() {
+               $cache = new HashBagOStuff( [ 'maxKeys' => -1 ] );
+       }
+
+       /**
+        * @covers HashBagOStuff::__construct
+        * @expectedException InvalidArgumentException
+        */
+       public function testConstructBadType() {
+               $cache = new HashBagOStuff( [ 'maxKeys' => 'x' ] );
+       }
+
        /**
         * @covers HashBagOStuff::delete
         */
@@ -56,7 +90,6 @@ class HashBagOStuffTest extends PHPUnit_Framework_TestCase {
        /**
         * Ensure maxKeys eviction prefers keeping new keys.
         *
-        * @covers HashBagOStuff::__construct
         * @covers HashBagOStuff::set
         */
        public function testEvictionAdd() {
@@ -76,7 +109,6 @@ class HashBagOStuffTest extends PHPUnit_Framework_TestCase {
         * Ensure maxKeys eviction prefers recently set keys
         * even if the keys pre-exist.
         *
-        * @covers HashBagOStuff::__construct
         * @covers HashBagOStuff::set
         */
        public function testEvictionSet() {
@@ -102,7 +134,6 @@ class HashBagOStuffTest extends PHPUnit_Framework_TestCase {
        /**
         * Ensure maxKeys eviction prefers recently retrieved keys (LRU).
         *
-        * @covers HashBagOStuff::__construct
         * @covers HashBagOStuff::doGet
         * @covers HashBagOStuff::hasKey
         */