Gizra / drupal-starter

Drupal 10 Starter with best practices
76 stars 39 forks source link

Allow $this->markEntityForCleanup to be disabled #743

Open mariano-dagostino opened 5 days ago

mariano-dagostino commented 5 days ago

The weitzman\DrupalTestTraits\ExistingSiteBase class uses $this->markEntityForCleanup to delete entities after tests.

It would be handy to have an option to retain these entities for debugging purposes.

Proposed solution:

<phpunit bootstrap=".bootstrap-fast.php" processIsolation="true">
  <php>

    <env name="DISABLE_MARK_ENTITIES_FOR_CLEANUP" value="TRUE"/>

More concise or better names welcome.

amitaibu commented 5 days ago

My trick is usually going into the markEntityForCleanup method and comment the method's body.

mgurjanov commented 5 days ago

I've been using what @amitaibu suggested. Also one from @AronNovak :

$html = $this->getSession()->getPage()->getOuterHtml();
file_put_contents('/var/www/html/web/' . md5($html) . '.html', $html);
mariano-dagostino commented 5 days ago

Maybe we can have a custom ddev command to make this even simpler. Like ddev phpunit-keep Test.php so if some test fail it can be easilly re-run keeping the created entities with one simple cli change.

bboro commented 5 days ago

You can also just add a die() before the end of the test and it will keep the entities btw.

mgurjanov commented 3 days ago

Or adding sleep().