Browse files

Tests for JDocumentXml

  • Loading branch information...
1 parent 61b39bc commit 479d416773f21e4b9a3be06acc121b27f839b73c @piotr-cz piotr-cz committed Mar 5, 2013
Showing with 38 additions and 44 deletions.
  1. +38 −44 tests/suites/unit/joomla/document/xml/JDocumentXMLTest.php
View
82 tests/suites/unit/joomla/document/xml/JDocumentXMLTest.php
@@ -50,59 +50,53 @@ protected function setUp()
*/
public function testRender()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
+ JResponse::clearHeaders();
- /**
- * Test...
- *
- * @todo Implement testGetHeadData().
- *
- * @return void
- */
- public function testGetHeadData()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
+ $this->object->setBuffer('Unit Test Buffer');
- /**
- * Test...
- *
- * @todo Implement testSetHeadData().
- *
- * @return void
- */
- public function testSetHeadData()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
+ $this->assertThat(
+ $this->object->render(),
+ $this->equalTo('Unit Test Buffer'),
+ 'We did not get the buffer back properly'
+ );
- /**
- * Test...
- *
- * @todo Implement testGetName().
- *
- * @return void
- */
- public function testGetName()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
+ $headers = JResponse::getHeaders();
+
+ $disposition = false;
+
+ foreach ($headers as $head)
+ {
+ if ($head['name'] == 'Content-disposition')
+ {
+ $this->assertThat(
+ $head['value'],
+ $this->stringContains('.xml'),
+ 'The content disposition did not include json extension'
+ );
+ $disposition = true;
+ }
+ }
+
+ $this->assertThat(
+ $disposition,
+ $this->equalTo(true),
+ 'No Content-disposition headers'
+ );
}
/**
- * Test...
- *
- * @todo Implement testSetName().
+ * We test both at once
*
* @return void
*/
- public function testSetName()
+ public function testGetAndSetName()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
+ $this->object->setName('unittestfilename');
+
+ $this->assertThat(
+ $this->object->getName(),
+ $this->equalTo('unittestfilename'),
+ 'setName or getName did not work'
+ );
}
}

0 comments on commit 479d416

Please sign in to comment.