Example #1
0
 /**
  * Runs the expectation.
  *
  * @param Closure $closure The closure to run/spin.
  */
 protected function _spin($closure)
 {
     if (($timeout = $this->timeout()) < 0) {
         $closure();
     } else {
         Code::spin($closure, $timeout);
     }
 }
Example #2
0
            $closure = function () {
                Code::spin("invalid", 1);
            };
            expect($closure)->toThrow(new InvalidArgumentException());
        });
        it("throws an exception on timeout", function () {
            $start = microtime(true);
            $closure = function () {
                Code::spin(function () {
                }, 1);
            };
            expect($closure)->toThrow(new TimeoutException('Timeout reached, execution aborted after 1 second(s).'));
            $end = microtime(true);
            expect($end - $start)->toBeGreaterThan(1);
        });
        it("respects the delay delay", function () {
            $start = microtime(true);
            $counter = 0;
            $closure = function () use(&$counter) {
                Code::spin(function () use(&$counter) {
                    $counter++;
                }, 1, 250000);
            };
            expect($closure)->toThrow(new TimeoutException('Timeout reached, execution aborted after 1 second(s).'));
            expect($counter)->toBeGreaterThan(3);
            expect($counter)->toBeLessThan(6);
            $end = microtime(true);
            expect($end - $start)->toBeGreaterThan(1);
        });
    });
});
Example #3
0
    $selenium = new Selenium2Driver('firefox', null, 'http://*****:*****@fsockopen('localhost', 4444);
        }, 5, true);
        fclose($fp);
    } catch (TimeoutException $e) {
        echo "Unable to run the WebDriver binary, abording.\n";
        $process->close();
        exit(-1);
    }
    return $chain->next();
});
Filter::register('register.globals', function ($chain) {
    $root = $this->suite();
    $root->mink = $mink = box('spec')->get('mink');
    $root->afterEach(function () use($mink) {
        $mink->resetSessions();
    });