コード例 #1
0
ファイル: FilterTest.php プロジェクト: serby/Atrox
 public function testJoin()
 {
     $blogDataSource = Mock_MySql_Blog::getDataSource();
     $entity = $blogDataSource->makeNew();
     $entity->set("Title", "This is the first blog");
     $entity->set("Description", "and this is the first description");
     $blogDataSource->create($entity);
     $blogCommentDataSource = Mock_MySql_BlogComment::getDataSource();
     $entity = $blogCommentDataSource->makeNew();
     $entity->set("BlogId", 2);
     $entity->set("Comment", "WTF");
     $blogCommentDataSource->create($entity);
     $entity = $blogCommentDataSource->makeNew();
     $entity->set("BlogId", 1);
     $entity->set("Comment", "Blog Comment");
     $blogCommentDataSource->create($entity);
     $blog = $entity->getRelation("BlogId");
     $filter = $blogCommentDataSource->makeFilter();
     $filter->addJoin($blogCommentDataSource->getTableName(), "BlogId", $blogDataSource->getTableName(), "Id");
     $filter->addConditional($blogDataSource->getTableName(), "Title", "This is the first blog");
     $dataset = $blogCommentDataSource->retrieve($filter);
     $this->assertType("Atrox_Core_Data_Dataset", $dataset);
     $this->assertType("Mock_BlogComment", $blogCommentRecord = $dataset->getNext());
     $this->assertEquals("Blog Comment", $blogCommentRecord->get("Comment"));
 }
コード例 #2
0
ファイル: SourceTest.php プロジェクト: serby/Atrox
 public function testValidate()
 {
     $dataSource = Mock_MySql_Blog::getDataSource();
     $entity = $dataSource->makeNew();
     $dataSource->validate($entity);
     $this->assertEquals(array("'Description' is required"), $this->application->getErrorHandler()->getErrors());
     $entity = $dataSource->makeNew();
     $entity->set("Title", "");
     $entity->set("Description", "");
     $dataSource->validate($entity);
     $this->assertEquals(array("'Title' is required", "'Description' is required"), $this->application->getErrorHandler()->getErrors());
 }