public function testMathFunctions()
 {
     $mapper = fixture_mapper('Blog');
     try {
         $this->assertEquals($mapper->first(array('SQRT(id)' => 2))->id, 4);
         $this->assertEquals($mapper->first(array('COS(id-1)' => 1))->id, 1);
         $this->assertEquals($mapper->first(array('COS(id-1) + COS(id-1) =' => 2))->id, 1);
     } catch (Exception $e) {
         $mapper->debug();
     }
 }
 /**
  * @depends testBlogPostInsert
  */
 public function testBlogCommentsRelationInsertByObject($postId)
 {
     $post = $this->blogMapper->get($postId);
     $commentMapper = fixture_mapper('Blog_Comments');
     // 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);
 }
Esempio n. 3
0
 /**
  * Setup/fixtures for each test
  */
 public function setUp()
 {
     // New mapper instance
     $this->blogMapper = fixture_mapper('Blog');
 }