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. if (self::is_windows()) {
  11. $this->markTestSkipped('Fork tests not a priority on Windows.');
  12. }
  13. // Ensure that file that will be created by forked process does not exist
  14. // before invocation.
  15. $test_file = UNISH_SANDBOX . '/fork_test.txt';
  16. if (file_exists($test_file)) {
  17. unlink($test_file);
  18. }
  19. // Sleep for a millisecond, then create the file
  20. $ev_php = "usleep(1000);fopen('$test_file','a');";
  21. drush_invoke_process("@none", "ev", array($ev_php), array(), array("fork" => TRUE));
  22. // Test file does not exist immediate after process forked
  23. $this->assertEquals(file_exists($test_file), FALSE);
  24. // Check every 100th of a second for up to 4 seconds to see if the file appeared
  25. $repetitions = 400;
  26. while (!file_exists($test_file) && ($repetitions > 0)) {
  27. usleep(10000);
  28. }
  29. // Assert that the file did finally appear
  30. $this->assertEquals(file_exists($test_file), TRUE);
  31. }
  32. }