public static function adapter() { if (self::$_adapter === NULL) { self::$_adapter = new phpDataMapper_Adapter_MySQL('localhost', 'phpdatamapper_test', 'root', ''); } return self::$_adapter; }
/** * @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); }
public function setUp() { $this->logEntryMapper = phpDataMapper_TestHelper::mapper('Logger', 'LogEntryMapper'); }
public function testAdapterInstance() { $this->assertTrue(phpDataMapper_TestHelper::adapter() instanceof phpDataMapper_Adapter_Interface); }
public function setUp() { $this->postMapper = phpDataMapper_TestHelper::mapper('Blogs', 'PostMapper'); }