Ver código fonte

Add missing tests for Predis\Profiles\ServerProfile::defineCommand().

Daniele Alessandri 13 anos atrás
pai
commit
23ed563e45
1 arquivos alterados com 28 adições e 0 exclusões
  1. 28 0
      tests/Predis/Profiles/ServerProfileTest.php

+ 28 - 0
tests/Predis/Profiles/ServerProfileTest.php

@@ -145,6 +145,34 @@ class ServerProfileTest extends StandardTestCase
         $this->assertNull($profile->getCommandClass('UNKNOWN'));
         $this->assertNull($profile->getCommandClass('UNKNOWN'));
     }
     }
 
 
+    /**
+     * @group disconnected
+     */
+    public function testDefineCommand()
+    {
+        $profile = ServerProfile::getDefault();
+        $command = $this->getMock('Predis\Commands\ICommand');
+
+        $profile->defineCommand('mock', get_class($command));
+
+        $this->assertTrue($profile->supportsCommand('mock'));
+        $this->assertTrue($profile->supportsCommand('MOCK'));
+
+        $this->assertSame(get_class($command), $profile->getCommandClass('mock'));
+    }
+
+    /**
+     * @group disconnected
+     * @expectedException InvalidArgumentException
+     * @expectedExceptionMessage Cannot register 'stdClass' as it is not a valid Redis command
+     */
+    public function testDefineInvalidCommand()
+    {
+        $profile = ServerProfile::getDefault();
+
+        $profile->defineCommand('mock', 'stdClass');
+    }
+
     /**
     /**
      * @group disconnected
      * @group disconnected
      */
      */