public static function setUpBeforeClass() { parent::setUpBeforeClass(); SecurityTestHelper::createSuperAdmin(); $super = User::getByUsername('super'); ProjectTestHelper::createProjectByNameForOwner('testProject', $super); }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); SecurityTestHelper::createSuperAdmin(); $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; Currency::makeBaseCurrency(); //Create a Project for testing. ProjectTestHelper::createProjectByNameForOwner('superProject', $super); //Create a account for testing. $account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super); }
/** * @deletes selected projects. */ public function testRegularMassDeleteActionsForSelectedIds() { $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); $confused = User::getByUsername('confused'); $nobody = User::getByUsername('nobody'); $this->assertEquals(Right::DENY, $confused->getEffectiveRight('ZurmoModule', ZurmoModule::RIGHT_BULK_DELETE)); $confused->setRight('ZurmoModule', ZurmoModule::RIGHT_BULK_DELETE); //Load MassDelete view $projects = Project::getAll(); $this->assertEquals(9, count($projects)); $project1 = ProjectTestHelper::createProjectByNameForOwner('projectDelete1', $confused); $project2 = ProjectTestHelper::createProjectByNameForOwner('projectDelete2', $confused); $project3 = ProjectTestHelper::createProjectByNameForOwner('projectDelete3', $nobody); $project4 = ProjectTestHelper::createProjectByNameForOwner('projectDelete4', $confused); $project5 = ProjectTestHelper::createProjectByNameForOwner('projectDelete5', $confused); $project6 = ProjectTestHelper::createProjectByNameForOwner('projectDelete6', $nobody); $selectedIds = $project1->id . ',' . $project2->id . ',' . $project3->id; // Not Coding Standard $this->setGetArray(array('selectedIds' => $selectedIds, 'selectAll' => '')); // Not Coding Standard $this->resetPostArray(); $content = $this->runControllerWithNoExceptionsAndGetContent('projects/default/massDelete'); $this->assertContains('<strong>3</strong> Projects selected for removal', $content); $pageSize = Yii::app()->pagination->getForCurrentUserByType('massDeleteProgressPageSize'); $this->assertEquals(5, $pageSize); //calculating projects after adding 6 new records $projects = Project::getAll(); $this->assertEquals(15, count($projects)); //Deleting 6 opportunities for pagination scenario //Run Mass Delete using progress save for page1 $selectedIds = $project1->id . ',' . $project2->id . ',' . $project3->id . ',' . $project4->id . ',' . $project5->id . ',' . $project6->id; // Not Coding Standard $this->setGetArray(array('selectedIds' => $selectedIds, 'selectAll' => '', 'Project_page' => 1)); $this->setPostArray(array('selectedRecordCount' => 6)); $content = $this->runControllerWithExitExceptionAndGetContent('projects/default/massDelete'); $projects = Project::getAll(); $this->assertEquals(10, count($projects)); //Run Mass Delete using progress save for page2 $selectedIds = $project1->id . ',' . $project2->id . ',' . $project3->id . ',' . $project4->id . ',' . $project5->id . ',' . $project6->id; // Not Coding Standard $this->setGetArray(array('selectedIds' => $selectedIds, 'selectAll' => '', 'Project_page' => 2)); $this->setPostArray(array('selectedRecordCount' => 6)); $content = $this->runControllerWithNoExceptionsAndGetContent('projects/default/massDeleteProgress'); $projects = Project::getAll(); $this->assertEquals(9, count($projects)); }
protected function addProject($relatedFieldName) { $primaryModel = $this->getPrimaryModel(); $this->assertEquals(0, count($primaryModel->projects)); $project = ProjectTestHelper::createProjectByNameForOwner($this->modelClass . ' Project', Yii::app()->user->userModel); $project->{$relatedFieldName}->add($this->selectedModels[1]); assert($project->save()); // Not Coding Standard }
/** * @covers sortKanbanColumnItems * @covers checkKanbanTypeByStatusAndUpdateIfRequired */ public function testSortKanbanColumnItems() { Yii::app()->user->userModel = User::getByUsername('super'); $project = ProjectTestHelper::createProjectByNameForOwner('MyKanbanProject', Yii::app()->user->userModel); $dueStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 10000); //First kanban task $task = TaskTestHelper::createTaskByNameWithProjectAndStatus('MyFirstKanbanTask', Yii::app()->user->userModel, $project, Task::STATUS_IN_PROGRESS); $kanbanItem1 = KanbanItem::getByTask($task->id); $this->assertEquals(KanbanItem::TYPE_IN_PROGRESS, $kanbanItem1->type); $this->assertEquals($task->project->id, $kanbanItem1->kanbanRelatedItem->id); $task2 = TaskTestHelper::createTaskByNameWithProjectAndStatus('MySecondKanbanTask', Yii::app()->user->userModel, $project, Task::STATUS_IN_PROGRESS); $kanbanItem2 = KanbanItem::getByTask($task2->id); $this->assertEquals(KanbanItem::TYPE_IN_PROGRESS, $kanbanItem2->type); $this->assertEquals($task2->project->id, $kanbanItem2->kanbanRelatedItem->id); $task3 = TaskTestHelper::createTaskByNameWithProjectAndStatus('MyThirdKanbanTask', Yii::app()->user->userModel, $project, Task::STATUS_IN_PROGRESS); $kanbanItem3 = KanbanItem::getByTask($task3->id); $this->assertEquals(KanbanItem::TYPE_IN_PROGRESS, $kanbanItem3->type); $this->assertEquals($task3->project->id, $kanbanItem3->kanbanRelatedItem->id); $sourceKanbanType = TasksUtil::resolveKanbanItemTypeForTaskStatus(Task::STATUS_IN_PROGRESS); TasksUtil::sortKanbanColumnItems($sourceKanbanType, $task->project); $kanbanItem = KanbanItem::getByTask($task->id); $kanbanItem2 = KanbanItem::getByTask($task2->id); $kanbanItem3 = KanbanItem::getByTask($task3->id); $this->assertEquals($task->id, $kanbanItem->task->id); $this->assertEquals(1, $kanbanItem->sortOrder); $this->assertEquals($task2->id, $kanbanItem2->task->id); $this->assertEquals(2, $kanbanItem2->sortOrder); $this->assertEquals($task3->id, $kanbanItem3->task->id); $this->assertEquals(3, $kanbanItem3->sortOrder); //Update status and check checkKanbanTypeByStatusAndUpdateIfRequired $task->status = Task::STATUS_NEW; $this->assertTrue($task->save()); TasksUtil::checkKanbanTypeByStatusAndUpdateIfRequired($task); $kanbanItem = KanbanItem::getByTask($task->id); $this->assertEquals(KanbanItem::TYPE_SOMEDAY, $kanbanItem->type); $kanbanItem2 = KanbanItem::getByTask($task2->id); $this->assertEquals(KanbanItem::TYPE_IN_PROGRESS, $kanbanItem2->type); $kanbanItem3 = KanbanItem::getByTask($task3->id); $this->assertEquals(KanbanItem::TYPE_IN_PROGRESS, $kanbanItem3->type); $this->assertEquals($task->id, $kanbanItem->task->id); $this->assertEquals(1, $kanbanItem->sortOrder); $this->assertEquals($task2->id, $kanbanItem2->task->id); $this->assertEquals(1, $kanbanItem2->sortOrder); $this->assertEquals($task3->id, $kanbanItem3->task->id); $this->assertEquals(2, $kanbanItem3->sortOrder); }
public function testUpdateStatusOnDragInKanbanView() { $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); $project = ProjectTestHelper::createProjectByNameForOwner('a new project', $super); $task = TaskTestHelper::createTaskByNameForOwner('My Kanban Task', Yii::app()->user->userModel); $task->project = $project; $task->status = Task::STATUS_IN_PROGRESS; $taskId = $task->id; $this->assertTrue($task->save()); $task1 = TaskTestHelper::createTaskByNameForOwner('My Kanban Task 1', Yii::app()->user->userModel); $task1->project = $project; $task1->status = Task::STATUS_NEW; $this->assertTrue($task1->save()); $task1Id = $task1->id; $taskArray = array($task, $task1); foreach ($taskArray as $row => $data) { $kanbanItem = KanbanItem::getByTask($data->id); if ($kanbanItem == null) { //Create KanbanItem here $kanbanItem = TasksUtil::createKanbanItemFromTask($data); } $kanbanItemsArray[] = $kanbanItem; } $this->assertEquals(KanbanItem::TYPE_SOMEDAY, $kanbanItemsArray[1]->type); $this->assertEquals(1, $kanbanItemsArray[1]->sortOrder); $this->assertEquals(1, $kanbanItemsArray[0]->sortOrder); $this->setGetArray(array('items' => array($task1->id, $task->id), 'type' => KanbanItem::TYPE_IN_PROGRESS)); $content = $this->runControllerWithNoExceptionsAndGetContent('tasks/default/updateStatusOnDragInKanbanView', false); $contentArray = CJSON::decode($content); $this->assertContains('Finish', $contentArray['button']); $task1 = Task::getById($task1Id); $this->assertEquals(Task::STATUS_IN_PROGRESS, $task1->status); $kanbanItem = KanbanItem::getByTask($task1Id); $this->assertEquals(KanbanItem::TYPE_IN_PROGRESS, $kanbanItem->type); $kanbanItem = KanbanItem::getByTask($taskId); $this->assertEquals(2, $kanbanItem->sortOrder); }
public function testCloningWithAnotherProject() { $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); Yii::app()->user->userModel = $super; $project = ProjectTestHelper::createProjectByNameForOwner("My Project 1", $super); $id = $project->id; $this->setGetArray(array('id' => $id)); $content = $this->runControllerWithNoExceptionsAndGetContent('projects/default/copy'); $this->assertContains('My Project 1', $content); $projects = Project::getAll(); $this->assertEquals(1, count($projects)); }
/** * 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()); }