summaryrefslogtreecommitdiff
path: root/tests/simple_unit/SqlMap/InheritanceTest.php
diff options
context:
space:
mode:
authorctrlaltca <>2012-07-12 11:21:01 +0000
committerctrlaltca <>2012-07-12 11:21:01 +0000
commit903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 (patch)
treee08bf04f0823650a231227ac3499121270172a23 /tests/simple_unit/SqlMap/InheritanceTest.php
parent3e4e6e66aeb3f8fea4e1eb4237498ef9d2358f63 (diff)
standardize the use of unix eol; use svn properties to enforce native eol
Diffstat (limited to 'tests/simple_unit/SqlMap/InheritanceTest.php')
-rw-r--r--tests/simple_unit/SqlMap/InheritanceTest.php288
1 files changed, 144 insertions, 144 deletions
diff --git a/tests/simple_unit/SqlMap/InheritanceTest.php b/tests/simple_unit/SqlMap/InheritanceTest.php
index b0dd2dc9..82f86af3 100644
--- a/tests/simple_unit/SqlMap/InheritanceTest.php
+++ b/tests/simple_unit/SqlMap/InheritanceTest.php
@@ -1,145 +1,145 @@
-<?php
-
-require_once(dirname(__FILE__).'/BaseCase.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class InheritanceTest extends BaseCase
-{
- function __construct()
- {
- parent::__construct();
-
- $this->initSqlMap();
- $this->initScript('documents-init.sql');
- }
-
- /// Test All document with no formula
- function testGetAllDocument()
- {
- $list = $this->sqlmap->queryForList("GetAllDocument");
-
- $this->assertEqual(6, count($list));
- $book = $list[0];
- $this->assertBook($book, 1, "The World of Null-A", 55);
-
- $book = $list[1];
- $this->assertBook($book, 3, "Lord of the Rings", 3587);
-
- $document = $list[2];
- $this->assertDocument($document, 5, "Le Monde");
-
- $document = $list[3];
- $this->assertDocument($document, 6, "Foundation");
-
- $news = $list[4];
- $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon");
-
- $document = $list[5];
- $this->assertDocument($document, 4, "Le Canard enchaine");
- }
-
- /// Test All document in a typed collection
- function testGetTypedCollection()
- {
- $list = $this->sqlmap->queryForList("GetTypedCollection");
-
- $this->assertEqual(6, $list->getCount());
-
- $book = $list[0];
- $this->assertBook($book, 1, "The World of Null-A", 55);
-
- $book = $list[1];
- $this->assertBook($book, 3, "Lord of the Rings", 3587);
-
- $document = $list[2];
- $this->assertDocument($document, 5, "Le Monde");
-
- $document = $list[3];
- $this->assertDocument($document, 6, "Foundation");
-
- $news = $list[4];
- $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon");
-
- $document = $list[5];
- $this->assertDocument($document, 4, "Le Canard enchaine");
- }
-
- /// Test All document with Custom Type Handler
- function testGetAllDocumentWithCustomTypeHandler()
- {
-
- //register the custom inheritance type handler
- $this->sqlmap->registerTypeHandler(new CustomInheritance);
-
- $list = $this->sqlmap->queryForList("GetAllDocumentWithCustomTypeHandler");
-
- $this->assertEqual(6, count($list));
- $book = $list[0];
- $this->assertBook($book, 1, "The World of Null-A", 55);
-
- $book = $list[1];
- $this->assertBook($book, 3, "Lord of the Rings", 3587);
-
- $news = $list[2];
- $this->assertNewspaper($news, 5, "Le Monde", "Paris");
-
- $book = $list[3];
- $this->assertBook($book, 6, "Foundation", 557);
-
- $news = $list[4];
- $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon");
-
- $news = $list[5];
- $this->assertNewspaper($news, 4, "Le Canard enchaine", "Paris");
- }
-
- function AssertDocument(Document $document, $id, $title)
- {
- $this->assertEqual($id, $document->getID());
- $this->assertEqual($title, $document->getTitle());
- }
-
- function AssertBook(Book $book, $id, $title, $pageNumber)
- {
- $this->assertEqual($id, $book->getId());
- $this->assertEqual($title, $book->getTitle());
- $this->assertEqual($pageNumber, (int)$book->getPageNumber());
- }
-
- function AssertNewspaper(Newspaper $news, $id, $title, $city)
- {
- $this->assertEqual($id, $news->getId());
- $this->assertEqual($title, $news->getTitle());
- $this->assertEqual($city, $news->getCity());
- }
-}
-
-
-class CustomInheritance extends TSqlMapTypeHandler
-{
- public function getResult($type)
- {
- switch ($type)
- {
- case 'Monograph': case 'Book':
- return 'Book';
- case 'Tabloid': case 'Broadsheet': case 'Newspaper':
- return 'Newspaper';
- default:
- return 'Document';
- }
- }
-
- public function getParameter($parameter)
- {
- throw new TDataMapperException('not implemented');
- }
-
- public function createNewInstance($data=null)
- {
- throw new TDataMapperException('can not create');
- }
-}
+<?php
+
+require_once(dirname(__FILE__).'/BaseCase.php');
+
+/**
+ * @package System.DataAccess.SQLMap
+ */
+class InheritanceTest extends BaseCase
+{
+ function __construct()
+ {
+ parent::__construct();
+
+ $this->initSqlMap();
+ $this->initScript('documents-init.sql');
+ }
+
+ /// Test All document with no formula
+ function testGetAllDocument()
+ {
+ $list = $this->sqlmap->queryForList("GetAllDocument");
+
+ $this->assertEqual(6, count($list));
+ $book = $list[0];
+ $this->assertBook($book, 1, "The World of Null-A", 55);
+
+ $book = $list[1];
+ $this->assertBook($book, 3, "Lord of the Rings", 3587);
+
+ $document = $list[2];
+ $this->assertDocument($document, 5, "Le Monde");
+
+ $document = $list[3];
+ $this->assertDocument($document, 6, "Foundation");
+
+ $news = $list[4];
+ $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon");
+
+ $document = $list[5];
+ $this->assertDocument($document, 4, "Le Canard enchaine");
+ }
+
+ /// Test All document in a typed collection
+ function testGetTypedCollection()
+ {
+ $list = $this->sqlmap->queryForList("GetTypedCollection");
+
+ $this->assertEqual(6, $list->getCount());
+
+ $book = $list[0];
+ $this->assertBook($book, 1, "The World of Null-A", 55);
+
+ $book = $list[1];
+ $this->assertBook($book, 3, "Lord of the Rings", 3587);
+
+ $document = $list[2];
+ $this->assertDocument($document, 5, "Le Monde");
+
+ $document = $list[3];
+ $this->assertDocument($document, 6, "Foundation");
+
+ $news = $list[4];
+ $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon");
+
+ $document = $list[5];
+ $this->assertDocument($document, 4, "Le Canard enchaine");
+ }
+
+ /// Test All document with Custom Type Handler
+ function testGetAllDocumentWithCustomTypeHandler()
+ {
+
+ //register the custom inheritance type handler
+ $this->sqlmap->registerTypeHandler(new CustomInheritance);
+
+ $list = $this->sqlmap->queryForList("GetAllDocumentWithCustomTypeHandler");
+
+ $this->assertEqual(6, count($list));
+ $book = $list[0];
+ $this->assertBook($book, 1, "The World of Null-A", 55);
+
+ $book = $list[1];
+ $this->assertBook($book, 3, "Lord of the Rings", 3587);
+
+ $news = $list[2];
+ $this->assertNewspaper($news, 5, "Le Monde", "Paris");
+
+ $book = $list[3];
+ $this->assertBook($book, 6, "Foundation", 557);
+
+ $news = $list[4];
+ $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon");
+
+ $news = $list[5];
+ $this->assertNewspaper($news, 4, "Le Canard enchaine", "Paris");
+ }
+
+ function AssertDocument(Document $document, $id, $title)
+ {
+ $this->assertEqual($id, $document->getID());
+ $this->assertEqual($title, $document->getTitle());
+ }
+
+ function AssertBook(Book $book, $id, $title, $pageNumber)
+ {
+ $this->assertEqual($id, $book->getId());
+ $this->assertEqual($title, $book->getTitle());
+ $this->assertEqual($pageNumber, (int)$book->getPageNumber());
+ }
+
+ function AssertNewspaper(Newspaper $news, $id, $title, $city)
+ {
+ $this->assertEqual($id, $news->getId());
+ $this->assertEqual($title, $news->getTitle());
+ $this->assertEqual($city, $news->getCity());
+ }
+}
+
+
+class CustomInheritance extends TSqlMapTypeHandler
+{
+ public function getResult($type)
+ {
+ switch ($type)
+ {
+ case 'Monograph': case 'Book':
+ return 'Book';
+ case 'Tabloid': case 'Broadsheet': case 'Newspaper':
+ return 'Newspaper';
+ default:
+ return 'Document';
+ }
+ }
+
+ public function getParameter($parameter)
+ {
+ throw new TDataMapperException('not implemented');
+ }
+
+ public function createNewInstance($data=null)
+ {
+ throw new TDataMapperException('can not create');
+ }
+}
?> \ No newline at end of file