Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Drupal\Tests\ct_assignment\Kernel;
  4.  
  5. use Drupal\Core\DrupalKernel;
  6. use Drupal\Core\Site\Settings;
  7. use Drupal\Core\Url;
  8. use Drupal\KernelTests\KernelTestBase;
  9. use Drupal\Core\Cache\CacheableJsonResponse;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Component\HttpKernel\HttpKernelInterface;
  13. use Drupal\ct_assignment\Controller\AssignmentController;
  14. use Drupal\Core\Entity\EntityStorageException;
  15. use Drupal\Core\Form\FormState;
  16. use Drupal\entity_test\Entity\EntityTestMulRevPub;
  17. use Drupal\language\Entity\ConfigurableLanguage;
  18. use Drupal\system\Form\SiteInformationForm;
  19. use Drupal\Tests\field\Traits\EntityReferenceTestTrait;
  20. use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
  21. use Drupal\Tests\node\Traits\NodeCreationTrait;
  22. use Drupal\Tests\user\Traits\UserCreationTrait;
  23. use Drupal\views\Tests\ViewResultAssertionTrait;
  24. use Drupal\views\Views;
  25. use Drupal\node\Entity\Node;
  26. use Drupal\paragraphs\Entity\Paragraph;
  27.  
  28. /**
  29. * Tests assignment 3333333333.
  30. *
  31. * @group ct_assignment.
  32. */
  33. class AssignmentControllerTest extends KernelTestBase {
  34.  
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public static $modules = [
  39. 'ct_assignment',
  40. 'basic_auth',
  41. 'block',
  42. 'cas_server',
  43. 'content_translation',
  44. 'ct_book',
  45. 'ct_interactive_content',
  46. 'ct_rest_user',
  47. 'ct_teacher_resources',
  48. 'ct_tmf',
  49. 'datetime',
  50. 'entity_reference_revisions',
  51. 'field',
  52. 'file',
  53. 'image',
  54. 'jsonb',
  55. 'language',
  56. 'menu_ui',
  57. 'name',
  58. 'node',
  59. 'openid_connect',
  60. 'options',
  61. 'paragraphs',
  62. 'path',
  63. 'rest',
  64. 'serialization',
  65. 'simple_oauth',
  66. 'system',
  67. 'text',
  68. 'user',
  69. 'views',
  70. 'views_bulk_operations',
  71. 'workbench_moderation',
  72. ];
  73.  
  74. /**
  75. * {@inheritdoc}
  76. */
  77. protected function setUp() {
  78. parent::setUp();
  79.  
  80. $this->entityTypeManager = \Drupal::entityTypeManager();
  81.  
  82. $this->installEntitySchema('user');
  83. $this->installEntitySchema('node');
  84. $this->installEntitySchema('paragraph');
  85. }
  86.  
  87. /**
  88. * Tests on a route with a non-supported HTTP method.
  89. */
  90. public function testaddAssignment() {
  91.  
  92. $url = Url::fromRoute('ct_assignment.add_assignment');
  93. $this->assertEquals(\Drupal::request()->getBaseUrl() . '/add_assignment.json', $url->toString());
  94.  
  95. $result = new AssignmentController();
  96. $subrequest = Request::create('/add_assignment.json', 'GET',
  97. [
  98. 'uid' => '1706',
  99. 'title' => 'test',
  100. 'workbook' => '1',
  101. 'lesson' => '1',
  102. 'class_assignment' => '1',
  103. ]);
  104. $kernel = $this->container->get('http_kernel');
  105. $request = Request::create('/node/3');
  106. $response = $kernel->handle($request);
  107. $this->assertSame(301, $response->getStatusCode());
  108. $this->assertSame('/node/2', $response->getTargetUrl());
  109. $assignment = $result->addAssignment($subrequest);
  110. $this->assertEqual($assignment->getStatusCode(), TRUE);
  111. }
  112.  
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement