Skip to content
Snippets Groups Projects
Verified Commit 5afca8ca authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3469410 by catch, smustgrave: Speed up RevisionDeleteFormTest

parent 2258a66b
No related branches found
No related tags found
23 merge requests!12227Issue #3181946 by jonmcl, mglaman,!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!9470[10.3.x-only-DO-NOT-MERGE]: #3331771 Fix file_get_contents(): Passing null to parameter,!8736Update the Documention As per the Function uses.,!8513Issue #3453786: DefaultSelection should document why values for target_bundles NULL and [] behave as they do,!5423Draft: Resolve #3329907 "Test2",!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3478Issue #3337882: Deleted menus are not removed from content type config,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2062Issue #3246454: Add weekly granularity to views date sort,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #260711 passed with warnings
Pipeline: drupal

#260715

    ......@@ -42,6 +42,16 @@ protected function setUp(): void {
    $this->drupalPlaceBlock('page_title_block');
    }
    /**
    * Tests title by whether entity supports revision creation dates.
    */
    public function testPageTitle(): void {
    foreach (static::providerPageTitle() as $cases) {
    [$entityTypeId, $expectedQuestion] = $cases;
    $this->doTestPageTitle($entityTypeId, $expectedQuestion);
    }
    }
    /**
    * Tests title by whether entity supports revision creation dates.
    *
    ......@@ -51,9 +61,8 @@ protected function setUp(): void {
    * The expected question/page title.
    *
    * @covers ::getQuestion
    * @dataProvider providerPageTitle
    */
    public function testPageTitle(string $entityTypeId, string $expectedQuestion): void {
    protected function doTestPageTitle(string $entityTypeId, string $expectedQuestion): void {
    /** @var \Drupal\Core\Entity\RevisionableStorageInterface $storage */
    $storage = \Drupal::entityTypeManager()->getStorage($entityTypeId);
    ......@@ -112,12 +121,21 @@ public function testAccessDeleteLatestDefault(): void {
    $this->assertSession()->statusCodeEquals(403);
    }
    /**
    * Test that revisions can and can't be deleted in various scenarios.
    */
    public function testAccessDelete(): void {
    $this->testAccessDeleteLatestForwardRevision();
    $this->testAccessDeleteDefault();
    $this->testAccessDeleteNonLatest();
    }
    /**
    * Ensure that forward revision can be deleted.
    *
    * @covers \Drupal\Core\Entity\EntityAccessControlHandler::checkAccess
    */
    public function testAccessDeleteLatestForwardRevision(): void {
    protected function testAccessDeleteLatestForwardRevision(): void {
    /** @var \Drupal\entity_test\Entity\EntityTestRevPub $entity */
    $entity = EntityTestRevPub::create();
    $entity->setName('delete revision');
    ......@@ -143,7 +161,7 @@ public function testAccessDeleteLatestForwardRevision(): void {
    *
    * @covers \Drupal\Core\Entity\EntityAccessControlHandler::checkAccess
    */
    public function testAccessDeleteDefault(): void {
    protected function testAccessDeleteDefault(): void {
    /** @var \Drupal\entity_test\Entity\EntityTestRevPub $entity */
    $entity = EntityTestRevPub::create();
    $entity->setName('delete revision');
    ......@@ -178,7 +196,7 @@ public function testAccessDeleteDefault(): void {
    *
    * @covers \Drupal\Core\Entity\EntityAccessControlHandler::checkAccess
    */
    public function testAccessDeleteNonLatest(): void {
    protected function testAccessDeleteNonLatest(): void {
    /** @var \Drupal\entity_test\Entity\EntityTestRev $entity */
    $entity = EntityTestRev::create();
    $entity->setName('delete revision');
    ......@@ -198,6 +216,16 @@ public function testAccessDeleteNonLatest(): void {
    $this->assertTrue($revision->access('delete revision', $this->rootUser, FALSE));
    }
    /**
    * Tests revision deletion form.
    */
    public function testSubmitForm(): void {
    foreach (static::providerSubmitForm() as $case) {
    [$permissions, $entityTypeId, $entityLabel, $totalRevisions, $expectedLog, $expectedMessage, $expectedDestination] = $case;
    $this->doTestSubmitForm($permissions, $entityTypeId, $entityLabel, $totalRevisions, $expectedLog, $expectedMessage, $expectedDestination);
    }
    }
    /**
    * Tests revision deletion, and expected response after deletion.
    *
    ......@@ -218,9 +246,8 @@ public function testAccessDeleteNonLatest(): void {
    * Expected destination after deletion.
    *
    * @covers ::submitForm
    * @dataProvider providerSubmitForm
    */
    public function testSubmitForm(array $permissions, string $entityTypeId, string $entityLabel, int $totalRevisions, string $expectedLog, string $expectedMessage, $expectedDestination): void {
    protected function doTestSubmitForm(array $permissions, string $entityTypeId, string $entityLabel, int $totalRevisions, string $expectedLog, string $expectedMessage, $expectedDestination): void {
    if (count($permissions) > 0) {
    $this->drupalLogin($this->createUser($permissions));
    }
    ......@@ -273,6 +300,7 @@ public function testSubmitForm(array $permissions, string $entityTypeId, string
    $this->assertEquals([0 => $expectedLog], $logs);
    // Messenger message.
    $this->assertSession()->pageTextContains($expectedMessage);
    \Drupal::database()->delete('watchdog')->execute();
    }
    /**
    ......@@ -296,9 +324,9 @@ public static function providerSubmitForm(): array {
    'entity_test_rev',
    'view, view all revisions, delete revision',
    2,
    'entity_test_rev: deleted <em class="placeholder">view, view all revisions, delete revision</em> revision <em class="placeholder">1</em>.',
    'entity_test_rev: deleted <em class="placeholder">view, view all revisions, delete revision</em> revision <em class="placeholder">3</em>.',
    'Revision of Entity Test Bundle view, view all revisions, delete revision has been deleted.',
    '/entity_test_rev/1/revisions',
    '/entity_test_rev/2/revisions',
    ];
    $data['supporting revision log, one revision remaining after delete, no view access'] = [
    ......@@ -316,9 +344,9 @@ public static function providerSubmitForm(): array {
    'entity_test_revlog',
    'view, view all revisions, delete revision',
    2,
    'entity_test_revlog: deleted <em class="placeholder">view, view all revisions, delete revision</em> revision <em class="placeholder">1</em>.',
    'entity_test_revlog: deleted <em class="placeholder">view, view all revisions, delete revision</em> revision <em class="placeholder">3</em>.',
    'Revision from Sun, 11 Jan 2009 - 16:00 of Test entity - revisions log view, view all revisions, delete revision has been deleted.',
    '/entity_test_revlog/1/revisions',
    '/entity_test_revlog/2/revisions',
    ];
    return $data;
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment