tests/TestRedis.php
// can't be sure what's going on in the instance, but we can do some things.
can't be sure what's going on in the instance, but we can do some things.
can ' t be sure what ' s going on in the instance but we can do some things .
public function testPubSub() {
        if(version_compare($this->version, "2.8.0", "lt")) {
            $this->markTestSkipped();
            return;
        }
        $result = $this->redis->pubsub("channels", "*");
        $this->assertTrue(is_array($result));
        $result = $this->redis->pubsub("channels");
        $this->assertTrue(is_array($result));
        $c1 = uniqid() . '-' . rand(1,100);
        $c2 = uniqid() . '-' . rand(1,100);
        $result = $this->redis->pubsub("numsub", Array($c1, $c2));
        $this->assertTrue(is_array($result));
        $this->assertEquals(count($result), 2);
        foreach(Array($c1,$c2) as $channel) {
            $this->assertTrue(isset($result[$channel]));
            $this->assertEquals($result[$channel], 0);
        }
        $result = $this->redis->pubsub("numpat");
        $this->assertTrue(is_int($result));
        $this->assertFalse($this->redis->pubsub("notacommand"));
        $this->assertFalse($this->redis->pubsub("numsub", "not-an-array"));
    }
public function testPubSub ( ) { if ( version_compare ( $ this -> version , " 2.8.0 " , " lt " ) ) { $ this -> markTestSkipped ( ) ; return ; } $ result = $ this -> redis -> pubsub ( " channels " , " * " ) ; $ this -> assertTrue ( is_array ( $ result ) ) ; $ result = $ this -> redis -> pubsub ( " channels " ) ; $ this -> assertTrue ( is_array ( $ result ) ) ; $ c1 = uniqid ( ) . '-' . rand ( 1 , 100 ) ; $ c2 = uniqid ( ) . '-' . rand ( 1 , 100 ) ; $ result = $ this -> redis -> pubsub ( " numsub " , Array ( $ c1 , $ c2 ) ) ; $ this -> assertTrue ( is_array ( $ result ) ) ; $ this -> assertEquals ( count ( $ result ) , 2 ) ; foreach ( Array ( $ c1 , $ c2 ) as $ channel ) { $ this -> assertTrue ( isset ( $ result [ $ channel ] ) ) ; $ this -> assertEquals ( $ result [ $ channel ] , 0 ) ; } $ result = $ this -> redis -> pubsub ( " numpat " ) ; $ this -> assertTrue ( is_int ( $ result ) ) ; $ this -> assertFalse ( $ this -> redis -> pubsub ( " notacommand " ) ) ; $ this -> assertFalse ( $ this -> redis -> pubsub ( " numsub " , " not-an-array " ) ) ; }
can't be sure what's going on in the instance, but we can do some things.
can ' t be sure what ' s going on in the instance but we can do some things .
// Only available since 2.8.0 // PUBSUB CHANNELS ... // PUBSUB NUMSUB // Should get an array back, with two elements // Make sure the elements are correct, and have zero counts // PUBSUB NUMPAT // Invalid calls