backendUnitTest.php

  1. 8.0.x tests/backendUnitTest.php
  2. 7.x tests/backendUnitTest.php
  3. master tests/backendUnitTest.php

Namespace

Unish

Classes

Namesort descending Description
backendUnitCase

File

tests/backendUnitTest.php
View source
  1. <?php
  2. namespace Unish;
  3. class backendUnitCase extends UnitUnishTestCase {
  4. /**
  5. * Covers the following target responsibilities.
  6. * - Insures that drush_invoke_process() called with fork backend set is able
  7. * to invoke a non-blocking process.
  8. */
  9. function testBackendFork() {
  10. // Ensure that file that will be created by forked process does not exist
  11. // before invocation.
  12. $test_file = UNISH_SANDBOX . '/fork_test.txt';
  13. if (file_exists($test_file)) {
  14. unlink($test_file);
  15. }
  16. // Sleep for a millisecond, then create the file
  17. $ev_php = "usleep(1000);fopen('$test_file','a');";
  18. drush_invoke_process("@none", "ev", array($ev_php), array(), array("fork" => TRUE));
  19. // Test file does not exist immediate after process forked
  20. $this->assertEquals(file_exists($test_file), FALSE);
  21. // Check every 100th of a second for up to 4 seconds to see if the file appeared
  22. $repetitions = 400;
  23. while (!file_exists($test_file) && ($repetitions > 0)) {
  24. usleep(10000);
  25. }
  26. // Assert that the file did finally appear
  27. $this->assertEquals(file_exists($test_file), TRUE);
  28. }
  29. }