Project PHP Class Code Examples

This page contains top rated real world PHP examples of class Project extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: FixturesManager.php Project: emiliand/rest
0
 public function populateData()
 {
     $user = new User();
     $user->username = 'weaverryan';
     $user->email = 'ryan@knplabs.com';
     $user->setPlainPassword('foo');
     $userRepo = $this->app['repository.user'];
     $userRepo->save($user);
     $project1 = new Project();
     $project1->name = 'BurningBot';
     $project1->difficultyLevel = rand(1, 10);
     $projectRepo = $this->app['repository.project'];
     $projectRepo->save($project1);
     $project2 = new Project();
     $project2->name = 'InstaFaceTweet';
     $project2->difficultyLevel = rand(1, 10);
     $projectRepo = $this->app['repository.project'];
     $projectRepo->save($project2);
     $project3 = new Project();
     $project3->name = 'MountBox';
     $project3->difficultyLevel = rand(1, 10);
     $projectRepo = $this->app['repository.project'];
     $projectRepo->save($project3);
     $project4 = new Project();
     $project4->name = 'Video Game';
     $project4->difficultyLevel = rand(1, 10);
     $projectRepo = $this->app['repository.project'];
     $projectRepo->save($project4);
     $project5 = new Project();
     $project5->name = 'Bike Shop Project';
     $project5->difficultyLevel = rand(1, 10);
     $projectRepo = $this->app['repository.project'];
     $projectRepo->save($project5);
 }
Example #2
Show file File: ActionTaskAssignColorUserTest.php Project: rbertani/kanboard
0
 public function testExecute()
 {
     $action = new Action\TaskAssignColorUser($this->container, 1, Task::EVENT_ASSIGNEE_CHANGE);
     $action->setParam('user_id', 1);
     $action->setParam('color_id', 'blue');
     // We create a task in the first column
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $p = new Project($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'color_id' => 'green')));
     // We change the assignee
     $event = array('project_id' => 1, 'task_id' => 1, 'owner_id' => 5);
     // Our event should NOT be executed
     $this->assertFalse($action->execute(new GenericEvent($event)));
     // Our task should be assigned to nobody and have the green color
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(0, $task['owner_id']);
     $this->assertEquals('green', $task['color_id']);
     // We change the assignee
     $event = array('project_id' => 1, 'task_id' => 1, 'owner_id' => 1);
     // Our event should be executed
     $this->assertTrue($action->execute(new GenericEvent($event)));
     // Our task should be assigned to nobody and have the blue color
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(0, $task['owner_id']);
     $this->assertEquals('blue', $task['color_id']);
 }
Example #3
Show file File: GitActions.class.php Project: pombredanne/tuleap
0
 public function updateMirroring(Project $project, array $repositories, $selected_mirror_ids)
 {
     $current_mirror_ids_per_repository = $this->mirror_data_mapper->getListOfMirrorIdsPerRepositoryForProject($project);
     foreach ($repositories as $repository) {
         if (!isset($selected_mirror_ids[$repository->getId()]) || !is_array($selected_mirror_ids[$repository->getId()])) {
             continue;
         }
         $mirror_ids = array();
         foreach ($selected_mirror_ids[$repository->getId()] as $mirror_id => $should_be_mirrored) {
             if ($should_be_mirrored) {
                 $mirror_ids[] = $mirror_id;
             }
         }
         if (!$this->areThereAnyChanges($repository, $mirror_ids, $current_mirror_ids_per_repository)) {
             continue;
         }
         if (!$this->updateRepositoryMirrors($repository, $mirror_ids)) {
             $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_git', 'mirroring_mirroring_error'));
             return;
         }
     }
     $more_than_one_repository = count($repositories) > 1;
     if ($more_than_one_repository && !$selected_mirror_ids) {
         $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('plugin_git', 'mirroring_unmirroring_successful_plural'));
     } elseif ($more_than_one_repository && $selected_mirror_ids) {
         $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('plugin_git', 'mirroring_mirroring_successful_plural'));
     } elseif (!$more_than_one_repository && !$selected_mirror_ids) {
         $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('plugin_git', 'mirroring_unmirroring_successful'));
     } else {
         $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('plugin_git', 'mirroring_mirroring_successful'));
     }
 }
Example #4
Show file File: IntrospectionHelper.php Project: taryono/school
0
 /**
  * Get the the name for an element.
  * When possible the full classnam (phing.tasks.system.PropertyTask) will
  * be returned.  If not available (loaded in taskdefs or typedefs) then the
  * XML element name will be returned.
  *
  * @param Project $project
  * @param object $element The Task or type element.
  * @return string Fully qualified class name of element when possible.
  */
 function getElementName(Project $project, $element)
 {
     $taskdefs = $project->getTaskDefinitions();
     $typedefs = $project->getDataTypeDefinitions();
     // check if class of element is registered with project (tasks & types)
     // most element types don't have a getTag() method
     $elClass = get_class($element);
     if (!in_array('getTag', get_class_methods($elClass))) {
         // loop through taskdefs and typesdefs and see if the class name
         // matches (case-insensitive) any of the classes in there
         foreach (array_merge($taskdefs, $typedefs) as $elName => $class) {
             if (0 === strcasecmp($elClass, StringHelper::unqualify($class))) {
                 return $class;
             }
         }
         return "{$elClass} (unknown)";
     } else {
         // ->getTag() method does exist, so use it
         $elName = $element->getTag();
         if (isset($taskdefs[$elName])) {
             return $taskdefs[$elName];
         } elseif (isset($typedefs[$elName])) {
             return $typedefs[$elName];
         } else {
             return "{$elName} (unknown)";
         }
     }
 }
Example #5
Show file File: GitBackend.class.php Project: pombredanne/tuleap
0
 public function renameProject(Project $project, $newName)
 {
     if (is_dir(Git_Backend_Interface::GIT_ROOT_PATH . '/' . $project->getUnixName())) {
         return rename(Git_Backend_Interface::GIT_ROOT_PATH . '/' . $project->getUnixName(), Git_Backend_Interface::GIT_ROOT_PATH . '/' . $newName);
     }
     return true;
 }
Example #6
Show file File: RecorderEntry.php Project: Ingewikkeld/phing
0
 /**
  * Set the project associated with this recorder entry.
  *
  * @param Project $project the project instance
  */
 public function setProject(Project $project)
 {
     $this->project = $project;
     if ($this->project != null) {
         $this->project->addBuildListener($this);
     }
 }
Example #7
Show file File: BoardTest.php Project: rbertani/kanboard
0
 public function testMoveDownAndRemoveColumn()
 {
     $p = new Project($this->container);
     $b = new Board($this->container);
     // We create a project
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
     // We remove the second column
     $this->assertTrue($b->removeColumn(2));
     $columns = $b->getColumns(1);
     $this->assertNotEmpty($columns);
     $this->assertCount(3, $columns);
     $this->assertEquals(1, $columns[0]['position']);
     $this->assertEquals(3, $columns[1]['position']);
     $this->assertEquals(4, $columns[2]['position']);
     $this->assertEquals(1, $columns[0]['id']);
     $this->assertEquals(3, $columns[1]['id']);
     $this->assertEquals(4, $columns[2]['id']);
     // We move up the second column
     $this->assertTrue($b->moveDown(1, $columns[0]['id']));
     // Check the new positions
     $columns = $b->getColumns(1);
     $this->assertNotEmpty($columns);
     $this->assertCount(3, $columns);
     $this->assertEquals(1, $columns[0]['position']);
     $this->assertEquals(2, $columns[1]['position']);
     $this->assertEquals(3, $columns[2]['position']);
     $this->assertEquals(3, $columns[0]['id']);
     $this->assertEquals(1, $columns[1]['id']);
     $this->assertEquals(4, $columns[2]['id']);
 }
Example #8
Show file File: DataType.php Project: Ingewikkeld/phing
0
 /**
  * Check to see whether any DataType we hold references to is
  * included in the Stack (which holds all DataType instances that
  * directly or indirectly reference this instance, including this
  * instance itself).
  *
  * If one is included, throw a BuildException created by circularReference
  *
  * This implementation is appropriate only for a DataType that
  * cannot hold other DataTypes as children.
  *
  * The general contract of this method is that it shouldn't do
  * anything if checked is true and set it to true on exit.
  *
  * @param $stk
  * @param Project $p
  *
  * @return void
  *
  * @throws BuildException
  */
 public function dieOnCircularReference(&$stk, Project $p)
 {
     if ($this->checked || !$this->isReference()) {
         return;
     }
     $o = $this->ref->getReferencedObject($p);
     if ($o instanceof DataType) {
         // TESTME - make sure that in_array() works just as well here
         //
         // check if reference is in stack
         //$contains = false;
         //for ($i=0, $size=count($stk); $i < $size; $i++) {
         //    if ($stk[$i] === $o) {
         //        $contains = true;
         //        break;
         //    }
         //}
         if (in_array($o, $stk, true)) {
             // throw build exception
             throw $this->circularReference();
         } else {
             array_push($stk, $o);
             $o->dieOnCircularReference($stk, $p);
             array_pop($stk);
         }
     }
     $this->checked = true;
 }
Example #9
Show file File: SubtaskTest.php Project: peripatetic-sojourner/kanboard
0
 public function testDuplicate()
 {
     $tc = new TaskCreation($this->container);
     $s = new Subtask($this->container);
     $p = new Project($this->container);
     // We create a project
     $this->assertEquals(1, $p->create(array('name' => 'test1')));
     // We create 2 tasks
     $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1)));
     $this->assertEquals(2, $tc->create(array('title' => 'test 2', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 0)));
     // We create many subtasks for the first task
     $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1, 'time_estimated' => 5, 'time_spent' => 3, 'status' => 1, 'another_subtask' => 'on')));
     $this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1, 'time_estimated' => '', 'time_spent' => '', 'status' => 2, 'user_id' => 1)));
     // We duplicate our subtasks
     $this->assertTrue($s->duplicate(1, 2));
     $subtasks = $s->getAll(2);
     $this->assertNotFalse($subtasks);
     $this->assertNotEmpty($subtasks);
     $this->assertEquals(2, count($subtasks));
     $this->assertEquals('subtask #1', $subtasks[0]['title']);
     $this->assertEquals('subtask #2', $subtasks[1]['title']);
     $this->assertEquals(2, $subtasks[0]['task_id']);
     $this->assertEquals(2, $subtasks[1]['task_id']);
     $this->assertEquals(5, $subtasks[0]['time_estimated']);
     $this->assertEquals(0, $subtasks[1]['time_estimated']);
     $this->assertEquals(0, $subtasks[0]['time_spent']);
     $this->assertEquals(0, $subtasks[1]['time_spent']);
     $this->assertEquals(0, $subtasks[0]['status']);
     $this->assertEquals(0, $subtasks[1]['status']);
     $this->assertEquals(0, $subtasks[0]['user_id']);
     $this->assertEquals(0, $subtasks[1]['user_id']);
     $this->assertEquals(1, $subtasks[0]['position']);
     $this->assertEquals(2, $subtasks[1]['position']);
 }
Example #10
Show file File: PHPUnitTestRunner.php Project: RadioCampusFrance/airtime
0
 public function __construct(Project $project, $groups = array(), $excludeGroups = array())
 {
     $this->project = $project;
     $this->groups = $groups;
     $this->excludeGroups = $excludeGroups;
     $this->retCode = self::SUCCESS;
 }
Example #11
Show file File: ProjectActivityTest.php Project: rbertani/kanboard
0
 public function testCleanup()
 {
     $e = new ProjectActivity($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $p = new Project($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'Project #1')));
     $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
     $max = 15;
     $nb_events = 100;
     for ($i = 0; $i < $nb_events; $i++) {
         $this->assertTrue($e->createEvent(1, 1, 1, Task::EVENT_CLOSE, array('task' => $tf->getbyId(1))));
     }
     $this->assertEquals($nb_events, $this->container['db']->table('project_activities')->count());
     $e->cleanup($max);
     $events = $e->getProject(1);
     $this->assertNotEmpty($events);
     $this->assertTrue(is_array($events));
     $this->assertEquals($max, count($events));
     $this->assertEquals(100, $events[0]['id']);
     $this->assertEquals(99, $events[1]['id']);
     $this->assertEquals(86, $events[14]['id']);
     // Cleanup during task creation
     $nb_events = ProjectActivity::MAX_EVENTS + 10;
     for ($i = 0; $i < $nb_events; $i++) {
         $this->assertTrue($e->createEvent(1, 1, 1, Task::EVENT_CLOSE, array('task' => $tf->getbyId(1))));
     }
     $this->assertEquals(ProjectActivity::MAX_EVENTS, $this->container['db']->table('project_activities')->count());
 }
Example #12
Show file File: TaskDuplicationTest.php Project: Folcky/kanboard
0
 public function testDuplicateRecurringTask()
 {
     $td = new TaskDuplication($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $p = new Project($this->container);
     $c = new Category($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'test1')));
     $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'date_due' => 1436561776, 'recurrence_status' => Task::RECURRING_STATUS_PENDING, 'recurrence_trigger' => Task::RECURRING_TRIGGER_CLOSE, 'recurrence_factor' => 2, 'recurrence_timeframe' => Task::RECURRING_TIMEFRAME_DAYS, 'recurrence_basedate' => Task::RECURRING_BASEDATE_TRIGGERDATE)));
     $this->assertEquals(2, $td->duplicateRecurringTask(1));
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(Task::RECURRING_STATUS_PROCESSED, $task['recurrence_status']);
     $this->assertEquals(2, $task['recurrence_child']);
     $this->assertEquals(1436561776, $task['date_due'], '', 2);
     $task = $tf->getById(2);
     $this->assertNotEmpty($task);
     $this->assertEquals(Task::RECURRING_STATUS_PENDING, $task['recurrence_status']);
     $this->assertEquals(Task::RECURRING_TRIGGER_CLOSE, $task['recurrence_trigger']);
     $this->assertEquals(Task::RECURRING_TIMEFRAME_DAYS, $task['recurrence_timeframe']);
     $this->assertEquals(Task::RECURRING_BASEDATE_TRIGGERDATE, $task['recurrence_basedate']);
     $this->assertEquals(1, $task['recurrence_parent']);
     $this->assertEquals(2, $task['recurrence_factor']);
     $this->assertEquals(strtotime('+2 days'), $task['date_due'], '', 2);
 }
Example #13
Show file File: TaskExternalLinkTest.php Project: perburn/kanboard
0
 public function testGetAll()
 {
     $this->container['sessionStorage']->user = array('id' => 1);
     $this->container['externalLinkManager'] = new ExternalLinkManager($this->container);
     $projectModel = new Project($this->container);
     $taskCreationModel = new TaskCreation($this->container);
     $taskExternalLinkModel = new TaskExternalLink($this->container);
     $webLinkProvider = new WebLinkProvider($this->container);
     $this->container['externalLinkManager']->register($webLinkProvider);
     $this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
     $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Test', 'project_id' => 1)));
     $this->assertEquals(1, $taskExternalLinkModel->create(array('task_id' => 1, 'url' => 'https://miniflux.net/', 'title' => 'MX', 'link_type' => 'weblink', 'dependency' => 'related')));
     $this->assertEquals(2, $taskExternalLinkModel->create(array('task_id' => 1, 'url' => 'http://kanboard.net/', 'title' => 'KB', 'link_type' => 'weblink', 'dependency' => 'related')));
     $links = $taskExternalLinkModel->getAll(1);
     $this->assertCount(2, $links);
     $this->assertEquals('KB', $links[0]['title']);
     $this->assertEquals('MX', $links[1]['title']);
     $this->assertEquals('Web Link', $links[0]['type']);
     $this->assertEquals('Web Link', $links[1]['type']);
     $this->assertEquals('Related', $links[0]['dependency_label']);
     $this->assertEquals('Related', $links[1]['dependency_label']);
     $this->assertEquals('admin', $links[0]['creator_username']);
     $this->assertEquals('admin', $links[1]['creator_username']);
     $this->assertEquals('', $links[0]['creator_name']);
     $this->assertEquals('', $links[1]['creator_name']);
 }
Example #14
Show file File: ProjectDailyColumnStatsTest.php Project: Folcky/kanboard
0
 public function testUpdateTotals()
 {
     $p = new Project($this->container);
     $pds = new ProjectDailyColumnStats($this->container);
     $tc = new TaskCreation($this->container);
     $ts = new TaskStatus($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
     $this->assertEquals(0, $pds->countDays(1, date('Y-m-d', strtotime('-2days')), date('Y-m-d')));
     for ($i = 0; $i < 10; $i++) {
         $this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 1)));
     }
     for ($i = 0; $i < 5; $i++) {
         $this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 4)));
     }
     $pds->updateTotals(1, date('Y-m-d', strtotime('-2days')));
     for ($i = 0; $i < 15; $i++) {
         $this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 3)));
     }
     for ($i = 0; $i < 25; $i++) {
         $this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 2)));
     }
     $pds->updateTotals(1, date('Y-m-d', strtotime('-1 day')));
     $this->assertNotFalse($ts->close(1));
     $this->assertNotFalse($ts->close(2));
     for ($i = 0; $i < 3; $i++) {
         $this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 3)));
     }
     for ($i = 0; $i < 5; $i++) {
         $this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 2)));
     }
     for ($i = 0; $i < 4; $i++) {
         $this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 4)));
     }
     $pds->updateTotals(1, date('Y-m-d'));
     $this->assertEquals(3, $pds->countDays(1, date('Y-m-d', strtotime('-2days')), date('Y-m-d')));
     $metrics = $pds->getAggregatedMetrics(1, date('Y-m-d', strtotime('-2days')), date('Y-m-d'));
     $this->assertNotEmpty($metrics);
     $this->assertEquals(4, count($metrics));
     $this->assertEquals(5, count($metrics[0]));
     $this->assertEquals('Date', $metrics[0][0]);
     $this->assertEquals('Backlog', $metrics[0][1]);
     $this->assertEquals('Ready', $metrics[0][2]);
     $this->assertEquals('Work in progress', $metrics[0][3]);
     $this->assertEquals('Done', $metrics[0][4]);
     $this->assertEquals(date('Y-m-d', strtotime('-2days')), $metrics[1][0]);
     $this->assertEquals(10, $metrics[1][1]);
     $this->assertEquals(0, $metrics[1][2]);
     $this->assertEquals(0, $metrics[1][3]);
     $this->assertEquals(5, $metrics[1][4]);
     $this->assertEquals(date('Y-m-d', strtotime('-1day')), $metrics[2][0]);
     $this->assertEquals(10, $metrics[2][1]);
     $this->assertEquals(25, $metrics[2][2]);
     $this->assertEquals(15, $metrics[2][3]);
     $this->assertEquals(5, $metrics[2][4]);
     $this->assertEquals(date('Y-m-d'), $metrics[3][0]);
     $this->assertEquals(10, $metrics[3][1]);
     $this->assertEquals(30, $metrics[3][2]);
     $this->assertEquals(18, $metrics[3][3]);
     $this->assertEquals(9, $metrics[3][4]);
 }
Example #15
Show file File: comments_on_item_block.inc.php Project: Bremaweb/streber-1
0
 protected function _render_commentField()
 {
     global $PH;
     echo "<div class=footer_form>";
     require_once confGet('DIR_STREBER') . "render/render_form.inc.php";
     $project = new Project($this->item_with_comments->project);
     $form = new PageForm();
     $form->button_cancel = false;
     $form->add(new Form_CustomHTML('<h3>' . __("Add Comment") . "</h3>"));
     ### Comment ###
     $comment_name = '';
     $comment = new Comment(array('id' => 0, 'name' => $comment_name));
     $e = $comment->fields['description']->getFormElement($comment, __('Comment'));
     $e->rows = 8;
     $form->add($e);
     $form->add($comment->fields['name']->getFormElement($comment, __('Summary')));
     ### request feedback
     $form->add(buildRequestFeedbackInput($project));
     /**
      * to reduce spam, enforce captcha test for guests
      */
     global $auth;
     if ($auth->cur_user->id == confGet('ANONYMOUS_USER')) {
         $form->addCaptcha();
     }
     ### some required hidden fields for correct data passing ###
     $form->add(new Form_HiddenField('comment_task', '', $this->item_with_comments->id));
     $form->add(new Form_HiddenField('comment', '', 0));
     if ($return = get('return')) {
         $form->add(new Form_HiddenField('return', '', asHtml($return)));
     }
     $PH->go_submit = 'commentEditSubmit';
     echo $form;
     echo "</div>";
 }
Example #16
Show file File: project.php Project: omusico/isle-web-framework
0
 public static function project($project_ID = NULL, $create = false)
 {
     if (!$project_ID) {
         global $ID;
         $project_ID = getNS($ID);
     }
     if (isset(self::$projects[$project_ID])) {
         return self::$projects[$project_ID];
     }
     $name = noNS($project_ID);
     $project_file = DOKU_DATA . implode('/', explode(':', $project_ID)) . "/{$name}.project";
     if (file_exists($project_file)) {
         $project = unserialize(file_get_contents($project_file));
         if (!method_exists($project, 'version') || $project->version() != PROJECTS_VERSION) {
             $project = new Project($project_ID);
             $project->rebuild();
         }
     } else {
         if ($create) {
             $project = new Project($project_ID);
         } else {
             return NULL;
         }
     }
     self::$projects[$project_ID] = $project;
     return $project;
 }
Example #17
Show file File: UseDefaultTemplate.php Project: jkhaled/Couscous
0
 public function __invoke(Project $project)
 {
     if ($this->useRemoteTemplate($project) || $this->hasCustomTemplateDirectory($project) || $this->hasTemplateDirectory($project)) {
         return;
     }
     $project->metadata['template.url'] = self::DEFAULT_TEMPLATE_URL;
 }
Example #18
Show file File: RuntimeConfigurable.php Project: dracony/forked-php-orm-benchmark
0
 /** Configure the wrapped element and all children. */
 function maybeConfigure(Project $project)
 {
     if ($this->proxyConfigured) {
         return;
     }
     $id = null;
     // DataType configured in ProjectConfigurator
     //        if ( is_a($this->wrappedObject, "DataType") )
     //            return;
     if ($this->attributes || $this->characters) {
         ProjectConfigurator::configure($this->wrappedObject, $this->attributes, $project);
         if (isset($this->attributes["id"])) {
             $id = $this->attributes["id"];
         }
         if ($this->characters) {
             ProjectConfigurator::addText($project, $this->wrappedObject, (string) $this->characters);
         }
         if ($id !== null) {
             $project->addReference($id, $this->wrappedObject);
         }
     }
     /*if ( is_array($this->children) && !empty($this->children) ) {
           // Configure all child of this object ...
           foreach($this->children as $child) {
               $child->maybeConfigure($project);
               ProjectConfigurator::storeChild($project, $this->wrappedObject, $child->wrappedObject, strtolower($child->getElementTag()));
           }
       }*/
     $this->proxyConfigured = true;
 }
Example #19
Show file File: ProjectManagerTest.php Project: fedegiust/Jumph
0
 public function testDelete()
 {
     $project = new Project();
     $this->objectManagerMock->shouldReceive('remove')->once()->with($project)->andReturn(true);
     $this->objectManagerMock->shouldReceive('flush')->once();
     $this->projectManager->delete($project);
 }
Example #20
Show file File: ProjectDuplicationTest.php Project: Folcky/kanboard
0
 public function testCloneProjectWithTasks()
 {
     $p = new Project($this->container);
     $pd = new ProjectDuplication($this->container);
     $s = new Swimlane($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'P1')));
     // create initial swimlanes
     $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'S1')));
     $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'S2')));
     $this->assertEquals(3, $s->create(array('project_id' => 1, 'name' => 'S3')));
     $default_swimlane1 = $s->getDefault(1);
     $default_swimlane1['default_swimlane'] = 'New Default';
     $this->assertTrue($s->updateDefault($default_swimlane1));
     //create initial tasks
     $this->assertEquals(1, $tc->create(array('title' => 'T1', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1)));
     $this->assertEquals(2, $tc->create(array('title' => 'T2', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1)));
     $this->assertEquals(3, $tc->create(array('title' => 'T3', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
     $this->assertNotFalse($pd->duplicate(1, array('category', 'action', 'task')));
     $project = $p->getByName('P1 (Clone)');
     $this->assertNotFalse($project);
     $project_id = $project['id'];
     // Check if Swimlanes have NOT been duplicated
     $this->assertCount(0, $s->getAll($project_id));
     // Check if Tasks have been duplicated
     $tasks = $tf->getAll($project_id);
     $this->assertCount(3, $tasks);
     //$this->assertEquals(4, $tasks[0]['id']);
     $this->assertEquals('T1', $tasks[0]['title']);
     //$this->assertEquals(5, $tasks[1]['id']);
     $this->assertEquals('T2', $tasks[1]['title']);
     //$this->assertEquals(6, $tasks[2]['id']);
     $this->assertEquals('T3', $tasks[2]['title']);
 }
Example #21
Show file File: FRSFileFactory.class.php Project: pombredanne/tuleap
0
 public function getSrcDir(Project $project)
 {
     $src_dir = $GLOBALS['ftp_incoming_dir'];
     $params = array('project' => $project, 'src_dir' => &$src_dir);
     EventManager::instance()->processEvent(Event::GET_FTP_INCOMING_DIR, $params);
     return $src_dir;
 }
Example #22
Show file File: AverageTimeSpentColumnAnalyticTest.php Project: peripatetic-sojourner/kanboard
0
 public function testAverageWithTransitions()
 {
     $transitionModel = new Transition($this->container);
     $taskFinderModel = new TaskFinder($this->container);
     $taskCreationModel = new TaskCreation($this->container);
     $projectModel = new Project($this->container);
     $averageLeadCycleTimeAnalytic = new AverageTimeSpentColumnAnalytic($this->container);
     $now = time();
     $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
     $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
     $this->assertEquals(2, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
     $this->container['db']->table(Task::TABLE)->eq('id', 1)->update(array('date_completed' => $now + 3600));
     $this->container['db']->table(Task::TABLE)->eq('id', 2)->update(array('date_completed' => $now + 1800));
     foreach (array(1, 2) as $task_id) {
         $task = $taskFinderModel->getById($task_id);
         $task['task_id'] = $task['id'];
         $task['date_moved'] = $now - 900;
         $task['src_column_id'] = 3;
         $task['dst_column_id'] = 1;
         $this->assertTrue($transitionModel->save(1, $task));
     }
     $stats = $averageLeadCycleTimeAnalytic->build(1);
     $expected = array(1 => array('count' => 2, 'time_spent' => 3600 + 1800, 'average' => (int) ((3600 + 1800) / 2), 'title' => 'Backlog'), 2 => array('count' => 0, 'time_spent' => 0, 'average' => 0, 'title' => 'Ready'), 3 => array('count' => 2, 'time_spent' => 1800, 'average' => 900, 'title' => 'Work in progress'), 4 => array('count' => 0, 'time_spent' => 0, 'average' => 0, 'title' => 'Done'));
     $this->assertEquals($expected, $stats);
 }
Example #23
Show file File: RuntimeConfigurable.php Project: taryono/school
0
 /** Configure the wrapped element and all children. */
 function maybeConfigure(Project $project)
 {
     $id = null;
     // DataType configured in ProjectConfigurator
     //        if ( is_a($this->wrappedObject, "DataType") )
     //            return;
     if ($this->attributes || $this->characters) {
         ProjectConfigurator::configure($this->wrappedObject, $this->attributes, $project);
         if (isset($this->attributes["id"])) {
             $id = $this->attributes["id"];
         }
         $this->attributes = null;
         if ($this->characters) {
             ProjectConfigurator::addText($project, $this->wrappedObject, (string) $this->characters);
             $this->characters = "";
         }
         if ($id !== null) {
             $project->addReference($id, $this->wrappedObject);
         }
     }
     if (is_array($this->children) && !empty($this->children)) {
         // Configure all child of this object ...
         foreach ($this->children as $child) {
             $child->maybeConfigure($project);
             ProjectConfigurator::storeChild($project, $this->wrappedObject, $child->wrappedObject, strtolower($child->getElementTag()));
         }
     }
 }
Example #24
Show file File: ActionTaskAssignColorCategoryTest.php Project: rbertani/kanboard
0
 public function testExecute()
 {
     $action = new Action\TaskAssignColorCategory($this->container, 1, Task::EVENT_CREATE_UPDATE);
     $action->setParam('category_id', 1);
     $action->setParam('color_id', 'blue');
     // We create a task in the first column
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $p = new Project($this->container);
     $c = new Category($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $this->assertEquals(1, $c->create(array('name' => 'c1')));
     $this->assertEquals(2, $c->create(array('name' => 'c2')));
     $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'color_id' => 'green', 'category_id' => 2)));
     // We create an event but we don't do anything
     $event = array('project_id' => 1, 'task_id' => 1, 'column_id' => 1, 'category_id' => 2, 'position' => 2);
     // Our event should NOT be executed
     $this->assertFalse($action->execute(new GenericEvent($event)));
     // Our task should be assigned to the ategory_id=1 and have the green color
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(2, $task['category_id']);
     $this->assertEquals('green', $task['color_id']);
     // We create an event to move the task
     $event = array('project_id' => 1, 'task_id' => 1, 'column_id' => 1, 'position' => 5, 'category_id' => 1);
     // Our event should be executed
     $this->assertTrue($action->execute(new GenericEvent($event)));
     // Our task should have the blue color
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals('blue', $task['color_id']);
 }
Example #25
Show file File: ProjectZurmoCopyModelUtilTest.php Project: RamaKavanan/InitialVersion
0
 public function testCopy()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $user = Yii::app()->user->userModel;
     $project = new Project();
     $project->name = 'Project 1';
     $project->owner = $user;
     $project->description = 'Description';
     $user = UserTestHelper::createBasicUser('Steven');
     $account = new Account();
     $account->owner = $user;
     $account->name = DataUtil::purifyHtml("Tom & Jerry's Account");
     $this->assertTrue($account->save());
     $id = $account->id;
     unset($account);
     $account = Account::getById($id);
     $this->assertEquals("Tom & Jerry's Account", $account->name);
     $contact = ContactTestHelper::createContactByNameForOwner('Jerry', $user);
     $opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('Jerry Opp', $user);
     $this->assertTrue($project->save());
     $this->assertEquals(1, count($project->auditEvents));
     $id = $project->id;
     $project->forget();
     unset($project);
     $project = Project::getById($id);
     ProjectZurmoControllerUtil::resolveProjectManyManyAccountsFromPost($project, array('accountIds' => $account->id));
     ProjectZurmoControllerUtil::resolveProjectManyManyContactsFromPost($project, array('contactIds' => $contact->id));
     ProjectZurmoControllerUtil::resolveProjectManyManyOpportunitiesFromPost($project, array('opportunityIds' => $opportunity->id));
     $this->assertEquals('Project 1', $project->name);
     $this->assertEquals('Description', $project->description);
     $this->assertEquals(1, $project->accounts->count());
     $this->assertEquals(1, $project->contacts->count());
     $this->assertEquals(1, $project->opportunities->count());
     $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);
     $copyToProject = new Project();
     ProjectZurmoCopyModelUtil::copy($project, $copyToProject);
     ProjectZurmoCopyModelUtil::processAfterCopy($project, $copyToProject);
     $this->assertTrue($copyToProject->save());
     $this->assertEquals($copyToProject->name, $project->name);
     $this->assertEquals($copyToProject->description, $project->description);
     $this->assertEquals($copyToProject->status, $project->status);
     $project = Project::getByName('Project 1');
     $this->assertEquals(2, count($project));
     $tasks = Task::getAll();
     $this->assertEquals(2, count($tasks));
 }
Example #26
Show file File: SOAPServerTest.php Project: pombredanne/tuleap
0
 private function setUpTrackers(TrackerFactory $tracker_factory, Project $project, Project $private_project)
 {
     $this->tracker = aMockTracker()->withId($this->tracker_id)->withProject($project)->withProjectId($project->getGroupId())->build();
     $this->unreadable_tracker = aMockTracker()->withId($this->unreadable_tracker_id)->withProject($project)->withProjectId($project->getGroupId())->build();
     $this->private_unreadable_tracker = aMockTracker()->withId($this->private_unreadable_tracker_id)->withProject($private_project)->withProjectId($private_project->getGroupId())->build();
     stub($this->tracker)->userCanView()->returns(true);
     stub($this->tracker)->userIsAdmin()->returns(true);
     stub($this->unreadable_tracker)->userCanView()->returns(false);
     stub($this->private_unreadable_tracker)->userCanView()->returns(true);
     stub($this->private_unreadable_tracker)->userIsAdmin()->returns(true);
     stub($tracker_factory)->getTrackerById($this->tracker_id)->returns($this->tracker);
     stub($tracker_factory)->getTrackerById($this->unreadable_tracker_id)->returns($this->unreadable_tracker);
     stub($tracker_factory)->getTrackerById($this->private_unreadable_tracker_id)->returns($this->private_unreadable_tracker);
 }
Example #27
Show file File: ProjectRoleVoterTest.php Project: phecho/gitonomy
0
 public function testNotCorrectProject()
 {
     $project = new Project('A', 'A');
     $projectOther = new Project('B', 'B');
     $token = $this->getToken(array('PROJECT_FOO', 'PROJECT_BAR'), $project);
     $voter = new ProjectRoleVoter();
     $this->assertEquals(ProjectRoleVoter::ACCESS_DENIED, $voter->vote($token, $projectOther, array('PROJECT_FOO')), "Cannot access another project");
 }
Example #28
Show file File: LoadProjectData.php Project: phecho/gitonomy
0
 /**
  * @inheritdoc
  */
 public function load(ObjectManager $manager)
 {
     $foobar = new Project('Foobar', 'foobar');
     $foobar->setRepositorySize(256);
     $foobar->setDefaultBranch('new-feature');
     $manager->persist($foobar);
     $this->setReference('project-foobar', $foobar);
     $this->dispatch($foobar);
     $empty = new Project('Empty', 'empty');
     $empty->setRepositorySize(256);
     $manager->persist($empty);
     $this->setReference('project-empty', $empty);
     $this->dispatch($empty);
     $barbaz = new Project('Barbaz', 'barbaz');
     $barbaz->setRepositorySize(352);
     $manager->persist($barbaz);
     $this->setReference('project-barbaz', $barbaz);
     $this->dispatch($barbaz);
     $secret = new Project('Secret', 'secret');
     $secret->setRepositorySize(564);
     $manager->persist($secret);
     $this->setReference('project-secret', $secret);
     $this->dispatch($secret);
     $manager->flush();
 }
Example #29
Show file File: ProjectConfigurator.php Project: altesien/FinalProject
0
 /**
  * Replace ${} style constructions in the given value with the
  * string value of the corresponding data types. This method is
  * static.
  *
  * @param  object  $project  the project that should be used for property look-ups
  * @param  string  $value    the string to be scanned for property references
  * @param  array   $keys     property keys
  * @param  integer $logLevel the level of generated log messages
  * @return string  the replaced string or <code>null</code> if the string
  *                 itself was null
  */
 public static function replaceProperties(Project $project, $value, $keys, $logLevel = Project::MSG_VERBOSE)
 {
     if ($value === null) {
         return null;
     }
     // These are a "hack" to support static callback for preg_replace_callback()
     // make sure these get initialized every time
     self::$propReplaceProperties = $keys;
     self::$propReplaceProject = $project;
     self::$propReplaceLogLevel = $logLevel;
     // Because we're not doing anything special (like multiple passes),
     // regex is the simplest / fastest.  PropertyTask, though, uses
     // the old parsePropertyString() method, since it has more stringent
     // requirements.
     $sb = $value;
     $iteration = 0;
     // loop to recursively replace tokens
     while (strpos($sb, '${') !== false) {
         $sb = preg_replace_callback('/\\$\\{([^\\$}]+)\\}/', array('ProjectConfigurator', 'replacePropertyCallback'), $sb);
         // keep track of iterations so we can break out of otherwise infinite loops.
         $iteration++;
         if ($iteration == 5) {
             return $sb;
         }
     }
     return $sb;
 }