Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Drupal\Tests\ct_assignment\Kernel;
- use Drupal\Core\DrupalKernel;
- use Drupal\Core\Site\Settings;
- use Drupal\Core\Url;
- use Drupal\KernelTests\KernelTestBase;
- use Drupal\Core\Cache\CacheableJsonResponse;
- use Symfony\Component\HttpFoundation\Request;
- use Symfony\Component\HttpFoundation\Response;
- use Symfony\Component\HttpKernel\HttpKernelInterface;
- use Drupal\ct_assignment\Controller\AssignmentController;
- use Drupal\Core\Entity\EntityStorageException;
- use Drupal\Core\Form\FormState;
- use Drupal\entity_test\Entity\EntityTestMulRevPub;
- use Drupal\language\Entity\ConfigurableLanguage;
- use Drupal\system\Form\SiteInformationForm;
- use Drupal\Tests\field\Traits\EntityReferenceTestTrait;
- use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
- use Drupal\Tests\node\Traits\NodeCreationTrait;
- use Drupal\Tests\user\Traits\UserCreationTrait;
- use Drupal\views\Tests\ViewResultAssertionTrait;
- use Drupal\views\Views;
- use Drupal\node\Entity\Node;
- use Drupal\paragraphs\Entity\Paragraph;
- /**
- * Tests assignment 3333333333.
- *
- * @group ct_assignment.
- */
- class AssignmentControllerTest extends KernelTestBase {
- /**
- * {@inheritdoc}
- */
- public static $modules = [
- 'ct_assignment',
- 'basic_auth',
- 'block',
- 'cas_server',
- 'content_translation',
- 'ct_book',
- 'ct_interactive_content',
- 'ct_rest_user',
- 'ct_teacher_resources',
- 'ct_tmf',
- 'datetime',
- 'entity_reference_revisions',
- 'field',
- 'file',
- 'image',
- 'jsonb',
- 'language',
- 'menu_ui',
- 'name',
- 'node',
- 'openid_connect',
- 'options',
- 'paragraphs',
- 'path',
- 'rest',
- 'serialization',
- 'simple_oauth',
- 'system',
- 'text',
- 'user',
- 'views',
- 'views_bulk_operations',
- 'workbench_moderation',
- ];
- /**
- * {@inheritdoc}
- */
- protected function setUp() {
- parent::setUp();
- $this->entityTypeManager = \Drupal::entityTypeManager();
- $this->installEntitySchema('user');
- $this->installEntitySchema('node');
- $this->installEntitySchema('paragraph');
- }
- /**
- * Tests on a route with a non-supported HTTP method.
- */
- public function testaddAssignment() {
- $url = Url::fromRoute('ct_assignment.add_assignment');
- $this->assertEquals(\Drupal::request()->getBaseUrl() . '/add_assignment.json', $url->toString());
- $result = new AssignmentController();
- $subrequest = Request::create('/add_assignment.json', 'GET',
- [
- 'uid' => '1706',
- 'title' => 'test',
- 'workbook' => '1',
- 'lesson' => '1',
- 'class_assignment' => '1',
- ]);
- $kernel = $this->container->get('http_kernel');
- $request = Request::create('/node/3');
- $response = $kernel->handle($request);
- $this->assertSame(301, $response->getStatusCode());
- $this->assertSame('/node/2', $response->getTargetUrl());
- $assignment = $result->addAssignment($subrequest);
- $this->assertEqual($assignment->getStatusCode(), TRUE);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement