/** * @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); }
/** * Setup/fixtures for each test */ public function setUp() { $this->postMapper = phpDataMapper_TestHelper::mapper('Blogs', 'PostMapper'); $this->dogMapper = phpDataMapper_TestHelper::mapper('Dogs', 'DogMapper'); }
public function setUp() { $this->logEntryMapper = phpDataMapper_TestHelper::mapper('Logger', 'LogEntryMapper'); }