public function testSettersAndGettersMethods() { $data = array('nickname' => 'my-nickname', 'password' => 'my-password', 'token' => 'my-token'); $phoneMock = m::mock(__NAMESPACE__ . '\\Phone'); $this->object->setNickname($data['nickname']); $this->object->setPassword($data['password']); $this->object->setToken($data['token']); $this->object->setPhone($phoneMock); $this->assertEquals($data['nickname'], $this->object->getNickname()); $this->assertEquals($data['password'], $this->object->getPassword()); $this->assertEquals($data['token'], $this->object->getToken()); $this->assertEquals($phoneMock, $this->object->getPhone()); }
/** * Authenticate with the Whatsapp Server. * * @param Connection $connection * @param Identity $identity * @param string $challengeData * @return string Returns binary string */ protected function getAuthData(Connection $connection, Identity $identity, $challengeData) { $keys = KeyStream::generateKeys(base64_decode($identity->getPassword()), $challengeData); $connection->setInputKey($this->createKeyStream($keys[2], $keys[3])); $connection->setOutputKey($this->createKeyStream($keys[0], $keys[1])); $array = "" . $identity->getPhone()->getPhoneNumber() . $challengeData; $response = $connection->getOutputKey()->encodeMessage($array, 0, 4, strlen($array) - 4); return $response; }