/** * Tests validateAndParseData method */ public function testValidateAndParseData() { $request = array('data' => 'abcdef', 'sign' => 'qwerty'); $parsed = array('projectid' => 123, 'someparam' => 'qwerty123', 'type' => 'micro'); $this->signer->expects($this->once())->method('checkSign')->with($request)->will($this->returnValue(true)); $this->util->expects($this->at(0))->method('decodeSafeUrlBase64')->with('abcdef')->will($this->returnValue('zxc')); $this->util->expects($this->at(1))->method('parseHttpQuery')->with('zxc')->will($this->returnValue($parsed)); $this->assertEquals($parsed, $this->validator->validateAndParseData($request)); }
/** * Tests checkSign with incorrect ss2 */ public function testCheckSignWithBadSignature() { $this->util->expects($this->once())->method('decodeSafeUrlBase64')->with('encoded-ss2')->will($this->returnValue('bad-ss2')); $this->assertFalse($this->signChecker->checkSign(array('data' => 'encodedData', 'ss1' => 'bad-ss1', 'ss2' => 'encoded-ss2'))); }
/** * Tests buildRepeatRequest method */ public function testBuildRepeatRequest() { $this->util->expects($this->once())->method('encodeSafeUrlBase64')->with('orderid=123&version=1.6&projectid=123&repeat_request=1')->will($this->returnValue('encoded')); $this->assertEquals(array('data' => 'encoded', 'sign' => md5('encodedsecret')), $this->builder->buildRepeatRequest(123)); }