Restore ticket test + fix chamilo installation through chash.

pull/2487/head
jmontoyaa 8 years ago
parent 7e9c4fb1cb
commit 4c22567da8
  1. 96
      main/install/index.php
  2. 98
      main/install/install.lib.php
  3. 20
      tests/behat/features/ticket.feature

@ -1,10 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session,
Chamilo\TicketBundle\Entity\Project as TicketProject,
Chamilo\TicketBundle\Entity\Category as TicketCategory,
Chamilo\TicketBundle\Entity\Priority as TicketPriority;
use ChamiloSession as Session;
/**
* Chamilo installation
@ -882,97 +879,6 @@ if (@$_POST['step2']) {
$connection->executeQuery("ALTER TABLE faq_question ADD CONSTRAINT FK_4A55B05912469DE2 FOREIGN KEY (category_id) REFERENCES faq_category (id);");
*/
// Add version table
$connection->executeQuery('CREATE TABLE IF NOT EXISTS version (id int unsigned NOT NULL AUTO_INCREMENT, version varchar(20), PRIMARY KEY(id), UNIQUE(version))');
// Tickets
$ticketProject = new TicketProject();
$ticketProject
->setId(1)
->setName('Ticket System')
->setInsertUserId(1);
$manager->persist($ticketProject);
$manager->flush();
$categories = array(
get_lang('TicketEnrollment') => get_lang('TicketsAboutEnrollment'),
get_lang('TicketGeneralInformation') => get_lang('TicketsAboutGeneralInformation'),
get_lang('TicketRequestAndPapework') => get_lang('TicketsAboutRequestAndPapework'),
get_lang('TicketAcademicIncidence') => get_lang('TicketsAboutAcademicIncidence'),
get_lang('TicketVirtualCampus') => get_lang('TicketsAboutVirtualCampus'),
get_lang('TicketOnlineEvaluation') => get_lang('TicketsAboutOnlineEvaluation')
);
$i = 1;
/**
* @var string $category
* @var string $description
*/
foreach ($categories as $category => $description) {
// Online evaluation requires a course
$ticketCategory = new TicketCategory();
$ticketCategory
->setId($i)
->setName($category)
->setDescription($description)
->setProject($ticketProject)
->setInsertUserId(1);
$isRequired = $i == 6;
$ticketCategory->setCourseRequired($isRequired);
$manager->persist($ticketCategory);
$manager->flush();
$i++;
}
// Default Priorities
$defaultPriorities = array(
TicketManager::PRIORITY_NORMAL => get_lang('PriorityNormal'),
TicketManager::PRIORITY_HIGH => get_lang('PriorityHigh'),
TicketManager::PRIORITY_LOW => get_lang('PriorityLow')
);
$table = Database::get_main_table(TABLE_TICKET_PRIORITY);
$i = 1;
foreach ($defaultPriorities as $code => $priority) {
$ticketPriority = new TicketPriority();
$ticketPriority
->setId($i)
->setName($priority)
->setCode($code)
->setInsertUserId(1);
$manager->persist($ticketPriority);
$manager->flush();
$i++;
}
$table = Database::get_main_table(TABLE_TICKET_STATUS);
// Default status
$defaultStatus = array(
TicketManager::STATUS_NEW => get_lang('StatusNew'),
TicketManager::STATUS_PENDING => get_lang('StatusPending'),
TicketManager::STATUS_UNCONFIRMED => get_lang('StatusUnconfirmed'),
TicketManager::STATUS_CLOSE => get_lang('StatusClose'),
TicketManager::STATUS_FORWARDED => get_lang('StatusForwarded')
);
$i = 1;
foreach ($defaultStatus as $code => $status) {
$attributes = array(
'id' => $i,
'code' => $code,
'name' => $status
);
Database::insert($table, $attributes);
$i++;
}
$sysPath = api_get_path(SYS_PATH);
finishInstallation(

@ -5,6 +5,9 @@ use Doctrine\ORM\EntityManager;
use Chamilo\CoreBundle\Entity\ExtraField;
use Chamilo\CoreBundle\Entity\ExtraFieldOptions;
use Chamilo\CoreBundle\Entity\ExtraFieldValues;
use Chamilo\TicketBundle\Entity\Project as TicketProject;
use Chamilo\TicketBundle\Entity\Category as TicketCategory;
use Chamilo\TicketBundle\Entity\Priority as TicketPriority;
/**
* Chamilo LMS
@ -2734,7 +2737,100 @@ function finishInstallation(
) {
$sysPath = !empty($sysPath) ? $sysPath : api_get_path(SYS_PATH);
// Inserting data
$connection = $manager->getConnection();
// Add version table
$connection->executeQuery('CREATE TABLE IF NOT EXISTS version (id int unsigned NOT NULL AUTO_INCREMENT, version varchar(20), PRIMARY KEY(id), UNIQUE(version))');
// Add tickets defaults
$ticketProject = new TicketProject();
$ticketProject
->setId(1)
->setName('Ticket System')
->setInsertUserId(1);
$manager->persist($ticketProject);
$manager->flush();
$categories = array(
get_lang('TicketEnrollment') => get_lang('TicketsAboutEnrollment'),
get_lang('TicketGeneralInformation') => get_lang('TicketsAboutGeneralInformation'),
get_lang('TicketRequestAndPapework') => get_lang('TicketsAboutRequestAndPapework'),
get_lang('TicketAcademicIncidence') => get_lang('TicketsAboutAcademicIncidence'),
get_lang('TicketVirtualCampus') => get_lang('TicketsAboutVirtualCampus'),
get_lang('TicketOnlineEvaluation') => get_lang('TicketsAboutOnlineEvaluation')
);
$i = 1;
/**
* @var string $category
* @var string $description
*/
foreach ($categories as $category => $description) {
// Online evaluation requires a course
$ticketCategory = new TicketCategory();
$ticketCategory
->setId($i)
->setName($category)
->setDescription($description)
->setProject($ticketProject)
->setInsertUserId(1);
$isRequired = $i == 6;
$ticketCategory->setCourseRequired($isRequired);
$manager->persist($ticketCategory);
$manager->flush();
$i++;
}
// Default Priorities
$defaultPriorities = array(
TicketManager::PRIORITY_NORMAL => get_lang('PriorityNormal'),
TicketManager::PRIORITY_HIGH => get_lang('PriorityHigh'),
TicketManager::PRIORITY_LOW => get_lang('PriorityLow')
);
$table = Database::get_main_table(TABLE_TICKET_PRIORITY);
$i = 1;
foreach ($defaultPriorities as $code => $priority) {
$ticketPriority = new TicketPriority();
$ticketPriority
->setId($i)
->setName($priority)
->setCode($code)
->setInsertUserId(1);
$manager->persist($ticketPriority);
$manager->flush();
$i++;
}
$table = Database::get_main_table(TABLE_TICKET_STATUS);
// Default status
$defaultStatus = array(
TicketManager::STATUS_NEW => get_lang('StatusNew'),
TicketManager::STATUS_PENDING => get_lang('StatusPending'),
TicketManager::STATUS_UNCONFIRMED => get_lang('StatusUnconfirmed'),
TicketManager::STATUS_CLOSE => get_lang('StatusClose'),
TicketManager::STATUS_FORWARDED => get_lang('StatusForwarded')
);
$i = 1;
foreach ($defaultStatus as $code => $status) {
$attributes = array(
'id' => $i,
'code' => $code,
'name' => $status
);
Database::insert($table, $attributes);
$i++;
}
// Inserting data.sql
$data = file_get_contents($sysPath.'main/install/data.sql');
$result = $manager->getConnection()->prepare($data);
$result->execute();

@ -21,16 +21,16 @@ Feature: Ticket
Given I am on "/main/ticket/priorities.php"
Then I should see "Normal"
# Scenario: Create a ticket
# Given I am on "/main/ticket/new_ticket.php?project_id=1"
# Then I should see "Compose message"
# When I fill in the following:
# | subject | First ticket |
# And I fill in ckeditor field "content" with "Ticket description"
# And I fill in select bootstrap static input "#category_id" select "1"
# #category id = 1 => Enrollment: Tickets about enrollment
# And I press "Send message"
# Then I should see "created"
Scenario: Create a ticket
Given I am on "/main/ticket/new_ticket.php?project_id=1"
Then I should see "Compose message"
When I fill in the following:
| subject | First ticket |
And I fill in ckeditor field "content" with "Ticket description"
And I fill in select bootstrap static input "#category_id" select "1"
#category id = 1 => Enrollment: Tickets about enrollment
And I press "Send message"
Then I should see "created"
#
# Scenario: Create ticket project
# Given I am on "/main/ticket/projects.php?action=add"

Loading…
Cancel
Save