JsonControllerTest.php 815 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. class JsonControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
  3. {
  4. protected function setUp()
  5. {
  6. $this->bootstrap = new Zend_Application(
  7. APPLICATION_ENV,
  8. APPLICATION_PATH . '/configs/application.ini'
  9. );
  10. parent::setUp();
  11. }
  12. public function testType1JsonSerialization()
  13. {
  14. $this->dispatch('/json');
  15. $this->assertModule('default');
  16. $this->assertController('json');
  17. $this->assertAction('index');
  18. $this->assertResponseCode(200);
  19. $this->assertHeaderRegex('Content-Type', '#^application/json$#');
  20. $content = $this->getResponse()->getBody();
  21. $this->assertSame('{"message":"Hello, World!"}', $content);
  22. $this->assertEquals(27, iconv_strlen($content, 'UTF-8'));
  23. }
  24. }