/** * @group pam * @group pam-user */ public function testNewInstancesWithAuthKey() { $this->pubnub_secret->grant(1, 1, $this->channel, 'admin_key', 10); $this->pubnub_secret->grant(1, 0, $this->channel, 'user_key', 10); $this->pubnub_secret->grant(0, 0, $this->channel, null, 10); $nonAuthorizedClient = new Pubnub(array('subscribe_key' => self::$subscribe, 'publish_key' => self::$publish)); $authorizedClient = new Pubnub(array('subscribe_key' => self::$subscribe, 'publish_key' => self::$publish, 'auth_key' => 'admin_key')); $authorizedResponse = $authorizedClient->publish($this->channel, 'hi'); $nonAuthorizedResponse = $nonAuthorizedClient->publish($this->channel, 'hi'); $this->assertEquals(1, $authorizedResponse[0]); $this->assertEquals(403, $nonAuthorizedResponse['status']); $nonAuthorizedClient->setAuthKey('admin_key'); $nonAuthorizedResponse = $nonAuthorizedClient->publish($this->channel, 'hi'); $this->assertEquals(1, $nonAuthorizedResponse[0]); }