Permalink
Browse files

Update document test.

  • Loading branch information...
1 parent 96cb6d2 commit 23d75999679da0b485132a175a38c4ea9bb7368a @jimsafley jimsafley committed Mar 14, 2012
Showing with 65 additions and 16 deletions.
  1. +65 −16 tests/document_test.php
View
@@ -6,7 +6,7 @@
*/
class TestDocument extends UnitTestCase
{
-
+ private $_testDocumentId;
private $_testDocument;
/**
@@ -17,20 +17,37 @@ public function __construct()
{
parent::__construct();
- // Assume TestAdapter has already verified the test adapter and test
- // document.
- $testAdapterClassName = TEST_ADAPTER_CLASS_NAME;
+ $this->_testDocumentId = TEST_DOCUMENT_ID;
+
+ // Assume TestAdapter has already verified the test adapter and the test
+ // document via the MediaWiki API client.
require_once TEST_ADAPTER_FILENAME;
+ require_once 'Scripto/Service/MediaWiki.php';
+ $testAdapterClassName = TEST_ADAPTER_CLASS_NAME;
// Instantiate the Scripto_Document object and set it.
require 'Scripto/Document.php';
- $this->_testDocument = new Scripto_Document(TEST_DOCUMENT_ID,
- new $testAdapterClassName,
- array('api_url' => TEST_MEDIAWIKI_API_URL,
- 'db_name' =>TEST_MEDIAWIKI_DB_NAME));
+ $this->_testDocument = new Scripto_Document(
+ $this->_testDocumentId,
+ new $testAdapterClassName,
+ new Scripto_Service_MediaWiki(TEST_MEDIAWIKI_API_URL, false)
+ );
}
- public function testDocumentIsValid()
+ public function testGetId()
+ {
+ $this->assertEqual($this->_testDocumentId, $this->_testDocument->getId());
+ }
+
+ public function testGetTitle()
+ {
+ $this->assertIsA($this->_testDocument->getTitle(), 'string');
+ }
+
+ /**
+ * Set the page for subsequent tests.
+ */
+ public function testPageIsValid()
{
// Assert a page has not been set yet.
$this->assertNull($this->_testDocument->getPageId(), 'The document page ID was prematurely set');
@@ -39,15 +56,47 @@ public function testDocumentIsValid()
$this->_testDocument->setPage(null);
$this->assertNotNull($this->_testDocument->getPageId(), 'The document page ID was not set');
- // Assert accessor methods return expected values.
- $this->assertIdentical(TEST_DOCUMENT_ID, $this->_testDocument->getId());
-
// Assert the decoding the base title works.
- $baseTitle = Scripto_Document::encodeBaseTitle($this->_testDocument->getId(),
- $this->_testDocument->getPageId());
+ $baseTitle = Scripto_Document::encodeBaseTitle($this->_testDocument->getId(), $this->_testDocument->getPageId());
$decodedBaseTitle = Scripto_Document::decodeBaseTitle($baseTitle);
- $this->assertEqual($decodedBaseTitle[0], TEST_DOCUMENT_ID, 'Something wen wrong during base title encoding/decoding. Document ID does not match');
- $this->assertEqual($decodedBaseTitle[1], $this->_testDocument->getPageId(), 'Something wen wrong during base title encoding/decoding. Page ID does not match');
+ $this->assertEqual($decodedBaseTitle[0], $this->_testDocumentId, 'Something went wrong during base title encoding/decoding. Document ID does not match');
+ $this->assertEqual($decodedBaseTitle[1], $this->_testDocument->getPageId(), 'Something went wrong during base title encoding/decoding. Page ID does not match');
+ }
+
+ public function testGetPageName()
+ {
+ $this->assertIsA($this->_testDocument->getPageName(), 'string');
+ }
+
+ public function testGetBaseTitle()
+ {
+ $this->assertIsA($this->_testDocument->getBaseTitle(), 'string');
+ }
+
+ public function testGetPages()
+ {
+ $this->assertIsA($this->_testDocument->getPages(), 'array');
+ }
+
+ public function testGetFirstPageId()
+ {
+ $firstPageId = $this->_testDocument->getFirstPageId();
+ $this->assertTrue((is_int($firstPageId) || is_string($firstPageId)));
+ }
+
+ public function testGetPageFileUrl()
+ {
+ $this->assertIsA($this->_testDocument->getPageFileUrl(), 'string');
+ }
+
+ public function testGetTranscriptionPageMediawikiUrl()
+ {
+ $this->assertIsA($this->_testDocument->getTranscriptionPageMediawikiUrl(), 'string');
+ }
+
+ public function testGetTalkPageMediawikiUrl()
+ {
+ $this->assertIsA($this->_testDocument->getTalkPageMediawikiUrl(), 'string');
}
}

0 comments on commit 23d7599

Please sign in to comment.