/** * 测试AuthLoggerListener::onVerifyPost() */ public function testOnVerifyPost() { $e = new Event(); $e->setQuery(array('code' => '1234567890')); $this->events->trigger(Event::EVENT_VERIFY_POST, $e); $this->assertStringMatchesFormat('%s INFO (6): 360, code: 1234567890%w', file_get_contents($this->destfile)); }
/** * 测试奇虎(360)的数据验证——成功 */ public function testOnVerifySuccess() { $id = rand(); $this->http->expects($this->once())->method('getAccessToken')->with($this->equalTo('valid_code'))->will($this->returnValue(array('access_token' => 'valid_token'))); $this->http->expects($this->once())->method('getUserInfo')->with($this->equalTo('valid_token'))->will($this->returnValue(array('id' => $id))); $e = new Event(); $e->setQuery(array('code' => 'valid_code')); $result = $this->http->onVerify($e); $this->assertArrayHasKey('id', $result); $this->assertEquals($id, $result['id']); }