/**
  * Walkthrough test for synchronous download
  */
 public function testAsynchronousDownloadDefaultControllerActions()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     Project::deleteAll();
     $projects = array();
     for ($i = 0; $i <= ExportModule::$asynchronousThreshold + 1; $i++) {
         $projects[] = ProjectTestHelper::createProjectByNameForOwner('superProject' . $i, $super);
     }
     Notification::deleteAll();
     NotificationMessage::deleteAll();
     $this->setGetArray(array('Project_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '1', 'selectedIds' => ''));
     $this->runControllerWithRedirectExceptionAndGetUrl('projects/default/export');
     // Start background job
     $job = new ExportJob();
     $this->assertTrue($job->run());
     $exportItems = ExportItem::getAll();
     $this->assertEquals(1, count($exportItems));
     $fileModel = $exportItems[0]->exportFileModel;
     $this->assertEquals(1, $exportItems[0]->isCompleted);
     $this->assertEquals('csv', $exportItems[0]->exportFileType);
     $this->assertEquals('projects', $exportItems[0]->exportFileName);
     $this->assertTrue($fileModel instanceof ExportFileModel);
     $this->assertEquals(1, Notification::getCount());
     $this->assertEquals(1, NotificationMessage::getCount());
     // Check export job, when many ids are selected.
     // This will probably never happen, but we need test for this case too.
     $notificationsBeforeCount = Notification::getCount();
     $notificationMessagesBeforeCount = NotificationMessage::getCount();
     // Now test case when multiple ids are selected
     $exportItems = ExportItem::deleteAll();
     $selectedIds = "";
     foreach ($projects as $project) {
         $selectedIds .= $project->id . ",";
         // Not Coding Standard
     }
     $this->setGetArray(array('ProjectsSearchForm' => array('anyMixedAttributesScope' => array(0 => 'All'), 'anyMixedAttributes' => ''), 'multiselect_ProjectsSearchForm_anyMixedAttributesScope' => 'All', 'Project_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '', 'selectedIds' => "{$selectedIds}"));
     $this->runControllerWithRedirectExceptionAndGetUrl('projects/default/export');
     // Start background job
     $job = new ExportJob();
     $this->assertTrue($job->run());
     $exportItems = ExportItem::getAll();
     $this->assertEquals(1, count($exportItems));
     $fileModel = $exportItems[0]->exportFileModel;
     $this->assertEquals(1, $exportItems[0]->isCompleted);
     $this->assertEquals('csv', $exportItems[0]->exportFileType);
     $this->assertEquals('projects', $exportItems[0]->exportFileName);
     $this->assertTrue($fileModel instanceof ExportFileModel);
     $this->assertEquals(2, Notification::getCount());
     $this->assertEquals(2, NotificationMessage::getCount());
 }