Returns 302 error in phpunit when the site redirection works fine
问题 When doing unit testing using PhpUnit in ZF2, the following message shows up: Failed asserting that 302 matches expected 200 I understand that it shown up because of the redirection command of ZF2: return $this->redirect()->toUrl('/admin/album/add'); But when I access it in the browser, the site works find with the above code. But it fails in the unit testing. What should I have to change? 回答1: A browser is not the same as unit testing or vice versa. Your expectations or results are different