Skip to content
Snippets Groups Projects
Commit 03f845bf authored by JohnCullen's avatar JohnCullen
Browse files

#3384913 Tested support_ticket.type_add GET request route and fixed all associated errors.

parent 5479d723
No related branches found
No related tags found
Loading
......@@ -50,35 +50,35 @@ class SupportTicketType extends ConfigEntityBundleBase implements SupportTicketT
*
* @var string
*/
protected $type;
protected string $type = '';
/**
* The human-readable name of the support ticket type.
*
* @var string
*/
protected $name;
protected string $name = '';
/**
* The human-readable name of the support ticket type.
*
* @var string
*/
protected $url;
protected string $url = '';
/**
* A brief description of this support ticket type.
*
* @var string
*/
protected string $description;
protected string $description = '';
/**
* Help information shown to the user when creating a Support Ticket.
*
* @var string
*/
protected string $help;
protected $help;
/**
* Default value of the 'Create new revision'.
......@@ -113,6 +113,8 @@ class SupportTicketType extends ConfigEntityBundleBase implements SupportTicketT
/**
* {@inheritdoc}
*
* @todo manage state using OOP principle if possible.
*/
public function isLocked() {
$locked = \Drupal::state()->get('support_ticket.type.locked');
......@@ -175,7 +177,9 @@ class SupportTicketType extends ConfigEntityBundleBase implements SupportTicketT
return $this->description;
}
/**
* {@inheritdoc}
*/
public function url() {
return $this->url;
}
......
......@@ -64,16 +64,15 @@ class SupportTicketTypeForm extends EntityForm {
public function form(array $form, FormStateInterface $form_state): array {
$form = parent::form($form, $form_state);
$type = $this->entity;
if ($this->operation == 'add') {
$form['#title'] = $this->t('Add support ticket type');
$fields = $this->entityFieldManager
->getBaseFieldDefinitions('support_ticket');
// Create a support ticket with a fake bundle using the type's
// UUID so that we can get the default values for workflow settings.
$support_ticket = $this->entityManager
$support_ticket_type = $this->entityManager
->getStorage('support_ticket')
->create(['support_ticket_type' => $type->uuid()]);
->create(['support_ticket_type' => $this->entity->uuid()]);
}
else {
$form['#title'] = $this->t('Edit %label support ticket type', ['%label' => $this->entity->label()]);
......@@ -81,9 +80,9 @@ class SupportTicketTypeForm extends EntityForm {
->getFieldDefinitions('support_ticket', $this->entity->id());
// Create a support_ticket to get the current values
// for workflow settings fields.
$support_ticket = $this->entityManager
$support_ticket_type = $this->entityManager
->getStorage('support_ticket')
->create(['support_ticket_type' => $type->id()]);
->create(['support_ticket_type' => $this->entity->id()]);
}
$form['name'] = [
......@@ -154,7 +153,7 @@ class SupportTicketTypeForm extends EntityForm {
$form['submission']['help'] = [
'#type' => 'textarea',
'#title' => $this->t('Explanation or submission guidelines'),
'#default_value' => '', //$this->entity->getHelp(),
'#default_value' => $this->entity->getHelp(),
'#description' => $this->t('This text will be displayed at the top of the page when creating or editing support tickets of this type.'),
];
......@@ -165,8 +164,8 @@ class SupportTicketTypeForm extends EntityForm {
];
$workflow_options = [
'status' => $support_ticket->isPublished(),
'locked' => $support_ticket->isLocked(),
'status' => $support_ticket_type->isPublished(),
'locked' => $support_ticket_type->isLocked(),
'revision' => $this->entity->isNewRevision(),
];
......
......@@ -38,7 +38,7 @@ class Http200ResponseRouteTests extends BrowserTestBase {
/**
* Testing drupal core path.
*/
public function testCorePageFunctionality() {
public function testCorePageFunctionality():void {
$admin_user = $this->drupalCreateUser(['access content overview']);
$this->drupalLogin($admin_user);
$this->drupalGet('/admin/content');
......@@ -48,7 +48,18 @@ class Http200ResponseRouteTests extends BrowserTestBase {
/**
* Testing support_ticket.type_add.
*/
public function testSupportTicketTypeAddFunctionality() {
public function testSupportTicketTypeAddFunctionality():void {
$admin_user = $this->drupalCreateUser(['administer support ticket types']);
$this->drupalLogin($admin_user);
$this->drupalGet('/admin/structure/support_ticket/ticket-types/add');
$this->assertSession()->statusCodeEquals(200);
}
/**
* Testing Post support_ticket.type_add.
*/
public function testSupportTicketPostTypeAddFunctionality():void {
// Example how to create post request to add data the form https://github.com/buildamodule/byfd8ws/blob/master/core/tests/Drupal/Tests/BrowserTestBase.php
$admin_user = $this->drupalCreateUser(['administer support ticket types']);
$this->drupalLogin($admin_user);
$this->drupalGet('/admin/structure/support_ticket/ticket-types/add');
......@@ -58,7 +69,7 @@ class Http200ResponseRouteTests extends BrowserTestBase {
/**
* Testing entity.support_ticket_type.collection.
*/
public function testSupportTicketTypeCollectionFunctionality() {
public function testSupportTicketTypeCollectionFunctionality():void {
$admin_user = $this->drupalCreateUser(['administer support ticket types']);
$this->drupalLogin($admin_user);
$this->drupalGet('/admin/structure/support_ticket/ticket-types');
......@@ -68,21 +79,21 @@ class Http200ResponseRouteTests extends BrowserTestBase {
/**
* Testing entity.support_ticket_type.delete_form.
*/
public function testSupportTicketTypeDeleteFormFunctionality() {
// $admin_user = $this->drupalCreateUser(['administer support ticket types']);
// $this->drupalLogin($admin_user);
// $this->drupalGet('/admin/structure/support_ticket/ticket-types/manage/{support_ticket_type}/delete');
// $this->assertSession()->statusCodeEquals(200);
public function testSupportTicketTypeDeleteFormFunctionality():void {
$admin_user = $this->drupalCreateUser(['administer support ticket types']);
$this->drupalLogin($admin_user);
// $this->drupalGet('/admin/structure/support_ticket/ticket-types/manage/{support_ticket_type}/delete');
// $this->assertSession()->statusCodeEquals(200);
}
/**
* Testing entity.support_ticket_type.edit_form.
*/
public function testSupportTicketTypeEditFormFunctionality() {
// $admin_user = $this->drupalCreateUser(['administer support ticket types']);
// $this->drupalLogin($admin_user);
// $this->drupalGet('/admin/structure/support_ticket/ticket-types/manage/{support_ticket_type}');
// $this->assertSession()->statusCodeEquals(200);
public function testSupportTicketTypeEditFormFunctionality():void {
$admin_user = $this->drupalCreateUser(['administer support ticket types']);
$this->drupalLogin($admin_user);
// $this->drupalGet('/admin/structure/support_ticket/ticket-types/manage/{support_ticket_type}');
// $this->assertSession()->statusCodeEquals(200);
}
}
......@@ -26,10 +26,19 @@ echo "";
##
# Run support module tests.
##
../../vendor/bin/phpunit ../modules/custom/support/tests/src/Functional/SupportInstallationTests.php
../../vendor/bin/phpunit ../modules/custom/support/modules/support_ticket/tests/src/Functional/SupportTicket/Http200ResponseRouteTests.php
../../vendor/bin/phpunit ../modules/custom/support/modules/support_ticket/tests/src/Functional/SupportTicketType/Http200ResponseRouteTests.php
#
# If "$1" is set by developer then a single set of tests will be run. If "$1" is
# null the entire test suite will be run.
##
if [ -z "$1" ]
then
../../vendor/bin/phpunit ../modules/custom/support/tests/src/Functional/SupportInstallationTests.php
../../vendor/bin/phpunit ../modules/custom/support/modules/support_ticket/tests/src/Functional/SupportTicket/Http200ResponseRouteTests.php
../../vendor/bin/phpunit ../modules/custom/support/modules/support_ticket/tests/src/Functional/SupportTicketType/Http200ResponseRouteTests.php
else
../../vendor/bin/phpunit $1
fi
##
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment