Exemple #1
0
 public static function adapter()
 {
     if (self::$_adapter === NULL) {
         self::$_adapter = new phpDataMapper_Adapter_MySQL('localhost', 'phpdatamapper_test', 'root', '');
     }
     return self::$_adapter;
 }
Exemple #2
0
 /**
  * @depends testBlogPostInsert
  */
 public function testBlogCommentsRelationInsertByObject($postId)
 {
     $post = $this->postMapper->get($postId);
     $commentMapper = phpDataMapper_TestHelper::mapper('Blogs', 'PostCommentsMapper');
     // Array will usually come from POST/JSON data or other source
     $commentSaved = false;
     $comment = $commentMapper->get()->data(array('post_id' => $postId, 'name' => 'Testy McTester', 'email' => '*****@*****.**', 'body' => 'This is a test comment. Yay!', 'date_created' => date($commentMapper->adapter()->dateTimeFormat())));
     try {
         $commentSaved = $commentMapper->save($comment);
         if (!$commentSaved) {
             print_r($commentMapper->errors());
             $this->fail("Comment NOT saved");
         }
     } catch (Exception $e) {
         echo $e->getTraceAsString();
         $commentMapper->debug();
         exit;
     }
     $this->assertTrue($commentSaved !== false);
 }
Exemple #3
0
 public function setUp()
 {
     $this->logEntryMapper = phpDataMapper_TestHelper::mapper('Logger', 'LogEntryMapper');
 }
Exemple #4
0
 public function testAdapterInstance()
 {
     $this->assertTrue(phpDataMapper_TestHelper::adapter() instanceof phpDataMapper_Adapter_Interface);
 }
 public function setUp()
 {
     $this->postMapper = phpDataMapper_TestHelper::mapper('Blogs', 'PostMapper');
 }