Laravel: RuntimeException: Unable to generate random string #44

Closed
isimmons opened this Issue Jun 7, 2013 · 11 comments

Projects

None yet

3 participants

@isimmons
isimmons commented Jun 7, 2013

Not sure of the specific details how this works but basically Laravel needs to create an instance of app to allow for full testing which at a point creates a session which needs to create a random number using Illuminate\Support\Str.php

There was 1 error:

1) SampleTest::testFoo
RuntimeException: Unable to generate random string.

C:\Users\lotus\projects\laravel_testing\vendor\laravel\framework\src\Illuminate\Support\Str.php:190
C:\Users\lotus\projects\laravel_testing\vendor\laravel\framework\src\Illuminate\Support\helpers.php:764
C:\Users\lotus\projects\laravel_testing\vendor\laravel\framework\src\Illuminate\Session\Store.php:14
C:\Users\lotus\projects\laravel_testing\vendor\laravel\framework\src\Illuminate\Session\SessionServiceProvider.php:108
C:\Users\lotus\projects\laravel_testing\vendor\laravel\framework\src\Illuminate\Foundation\Application.php:605
C:\Users\lotus\projects\laravel_testing\vendor\laravel\framework\src\Illuminate\Foundation\Application.php:564
C:\Users\lotus\projects\laravel_testing\vendor\laravel\framework\src\Illuminate\Foundation\start.php:208
C:\Users\lotus\projects\laravel_testing\bootstrap\start.php:61
C:\Users\lotus\projects\laravel_testing\app\tests\TestCase.php:16
C:\Users\lotus\projects\laravel_testing\vendor\laravel\framework\src\Illuminate\Foundation\Testing\TestCase.php:39
C:\Users\lotus\projects\laravel_testing\vendor\laravel\framework\src\Illuminate\Foundation\Testing\TestCase.php:29

FAILURES!
Tests: 1, Assertions: 0, Failures: 0, Errors: 1.

Here is the test.

<?php
class SampleTest extends TestCase {
    public function testFoo()
    {
        $this->assertTrue(true);
    }
}

I removed all other tests including the exampleTest.php shipped with Laravel. Changing to extend PHPUnit_Framework_TestCase directly from the test class resolves the issue for Paratest but certain testing in Laravel requires TestCase to be extended.

@brianium
Owner
brianium commented Jun 7, 2013

Wow. There is a lot going on in the bootstrap process for a Laravel TestCase. My guess is some sort of race condition is being presented. Will need to investigate this further.

@dbaltas
Collaborator
dbaltas commented Jun 7, 2013

I created a laravel master project as pointed out in http://laravel.com/docs/quick.
Paratest 0.4.4 works.(the default test passes)
Adding Paratest master on composer.json, and running

composer update

triggers this error: Class 'Patchwork\Utf8\Bootup' not found

Here is the sample laravel project: https://github.com/dbaltas/laravel-master with commands and their output in the README.

How could someone reproduce the "random string" issue?

@brianium
Owner
brianium commented Jun 7, 2013

@isimmons I just noticed you were running Windows. Are you using dev-master or 0.4.4?

@isimmons
isimmons commented Jun 7, 2013

For this error I am using dev-master. I just tried 0.4.4 and I get different results depending on if I install it locally or in the project its self. When I say globally I mean I created a folder in C:\php\paratest and then a bat file to call it so I don't have to install it in the project. This works with phpunit and codeception. Locally I'm using vendor\bin\paratest

Anyway, using 0.4.4 globally I get "Fatal Error class 'TestCase' not found. Not a problem for dev-master used globally.

0.4.4 locally I get a long list of errors


Strict standards: Non-static method PHP_Timer::start() should not be called statically, assuming $this from incompatible context in C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Runners\PHPUnit\ResultPrinter.php on line 40

Call Stack:
    0.0004     124912   1. {main}() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\bin\paratest:0
    0.0274    1148904   2. Symfony\Component\Console\Application->run() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\bin\paratest:35
    0.0354    1347416   3. ParaTest\Console\ParaTestApplication->doRun() C:\Users\lotus\projects\testing\laravel\vendor\symfony\console\Symfony\Component\Console\Application.php:121
    0.0376    1382280   4. Symfony\Component\Console\Application->doRun() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Console\ParaTestApplication.php:27
    0.0377    1382760   5. Symfony\Component\Console\Application->doRunCommand() C:\Users\lotus\projects\testing\laravel\vendor\symfony\console\Symfony\Component\Console\Application.php:184
    0.0377    1382944   6. Symfony\Component\Console\Command\Command->run() C:\Users\lotus\projects\testing\laravel\vendor\symfony\console\Symfony\Component\Console\Application.php:892
    0.0381    1383720   7. ParaTest\Console\Commands\ParaTestCommand->execute() C:\Users\lotus\projects\testing\laravel\vendor\symfony\console\Symfony\Component\Console\Command\Command.php:244
    0.0381    1383744   8. ParaTest\Console\Testers\PHPUnit->execute() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Console\Commands\ParaTestCommand.php:30
    0.0437    1483848   9. ParaTest\Runners\PHPUnit\Runner->run() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Console\Testers\PHPUnit.php:32
    0.0649    2211064  10. ParaTest\Runners\PHPUnit\ResultPrinter->start() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Runners\PHPUnit\Runner.php:28


Warning: array_push() expects parameter 1 to be array, null given in C:\Users\lotus\projects\testing\laravel\vendor\phpunit\php-timer\PHP\Timer.php on line 98

Call Stack:
    0.0004     124912   1. {main}() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\bin\paratest:0
    0.0274    1148904   2. Symfony\Component\Console\Application->run() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\bin\paratest:35
    0.0354    1347416   3. ParaTest\Console\ParaTestApplication->doRun() C:\Users\lotus\projects\testing\laravel\vendor\symfony\console\Symfony\Component\Console\Application.php:121
    0.0376    1382280   4. Symfony\Component\Console\Application->doRun() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Console\ParaTestApplication.php:27
    0.0377    1382760   5. Symfony\Component\Console\Application->doRunCommand() C:\Users\lotus\projects\testing\laravel\vendor\symfony\console\Symfony\Component\Console\Application.php:184
    0.0377    1382944   6. Symfony\Component\Console\Command\Command->run() C:\Users\lotus\projects\testing\laravel\vendor\symfony\console\Symfony\Component\Console\Application.php:892
    0.0381    1383720   7. ParaTest\Console\Commands\ParaTestCommand->execute() C:\Users\lotus\projects\testing\laravel\vendor\symfony\console\Symfony\Component\Console\Command\Command.php:244
    0.0381    1383744   8. ParaTest\Console\Testers\PHPUnit->execute() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Console\Commands\ParaTestCommand.php:30
    0.0437    1483848   9. ParaTest\Runners\PHPUnit\Runner->run() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Console\Testers\PHPUnit.php:32
    0.0649    2211064  10. ParaTest\Runners\PHPUnit\ResultPrinter->start() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Runners\PHPUnit\Runner.php:28
    0.0937    2220688  11. PHP_Timer->start() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Runners\PHPUnit\ResultPrinter.php:40
    0.0937    2221280  12. array_push() C:\Users\lotus\projects\testing\laravel\vendor\phpunit\php-timer\PHP\Timer.php:98

.
Strict standards: Non-static method PHP_Timer::resourceUsage() should not be called statically, assuming $this from incompatible context in C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Runners\PHPUnit\ResultPrinter.php on line 83

Call Stack:
    0.0004     124912   1. {main}() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\bin\paratest:0
    0.0274    1148904   2. Symfony\Component\Console\Application->run() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\bin\paratest:35
    0.0354    1347416   3. ParaTest\Console\ParaTestApplication->doRun() C:\Users\lotus\projects\testing\laravel\vendor\symfony\console\Symfony\Component\Console\Application.php:121
    0.0376    1382280   4. Symfony\Component\Console\Application->doRun() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Console\ParaTestApplication.php:27
    0.0377    1382760   5. Symfony\Component\Console\Application->doRunCommand() C:\Users\lotus\projects\testing\laravel\vendor\symfony\console\Symfony\Component\Console\Application.php:184
    0.0377    1382944   6. Symfony\Component\Console\Command\Command->run() C:\Users\lotus\projects\testing\laravel\vendor\symfony\console\Symfony\Component\Console\Application.php:892
    0.0381    1383720   7. ParaTest\Console\Commands\ParaTestCommand->execute() C:\Users\lotus\projects\testing\laravel\vendor\symfony\console\Symfony\Component\Console\Command\Command.php:244
    0.0381    1383744   8. ParaTest\Console\Testers\PHPUnit->execute() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Console\Commands\ParaTestCommand.php:30
    0.0437    1483848   9. ParaTest\Runners\PHPUnit\Runner->run() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Console\Testers\PHPUnit.php:32
    0.3918    2263944  10. ParaTest\Runners\PHPUnit\Runner->complete() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Runners\PHPUnit\Runner.php:35
    0.3918    2264016  11. ParaTest\Runners\PHPUnit\ResultPrinter->printResults() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Runners\PHPUnit\Runner.php:53
    0.3918    2264056  12. ParaTest\Runners\PHPUnit\ResultPrinter->getHeader() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Runners\PHPUnit\ResultPrinter.php:57


Fatal error: Call to undefined method ParaTest\Runners\PHPUnit\ResultPrinter::timeSinceStartOfRequest() in C:\Users\lotus\projects\testing\laravel\vendor\phpunit\php-timer\PHP\Timer.php on line 150

Call Stack:
    0.0004     124912   1. {main}() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\bin\paratest:0
    0.0274    1148904   2. Symfony\Component\Console\Application->run() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\bin\paratest:35
    0.0354    1347416   3. ParaTest\Console\ParaTestApplication->doRun() C:\Users\lotus\projects\testing\laravel\vendor\symfony\console\Symfony\Component\Console\Application.php:121
    0.0376    1382280   4. Symfony\Component\Console\Application->doRun() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Console\ParaTestApplication.php:27
    0.0377    1382760   5. Symfony\Component\Console\Application->doRunCommand() C:\Users\lotus\projects\testing\laravel\vendor\symfony\console\Symfony\Component\Console\Application.php:184
    0.0377    1382944   6. Symfony\Component\Console\Command\Command->run() C:\Users\lotus\projects\testing\laravel\vendor\symfony\console\Symfony\Component\Console\Application.php:892
    0.0381    1383720   7. ParaTest\Console\Commands\ParaTestCommand->execute() C:\Users\lotus\projects\testing\laravel\vendor\symfony\console\Symfony\Component\Console\Command\Command.php:244
    0.0381    1383744   8. ParaTest\Console\Testers\PHPUnit->execute() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Console\Commands\ParaTestCommand.php:30
    0.0437    1483848   9. ParaTest\Runners\PHPUnit\Runner->run() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Console\Testers\PHPUnit.php:32
    0.3918    2263944  10. ParaTest\Runners\PHPUnit\Runner->complete() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Runners\PHPUnit\Runner.php:35
    0.3918    2264016  11. ParaTest\Runners\PHPUnit\ResultPrinter->printResults() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Runners\PHPUnit\Runner.php:53
    0.3918    2264056  12. ParaTest\Runners\PHPUnit\ResultPrinter->getHeader() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Runners\PHPUnit\ResultPrinter.php:57
    0.4195    2264072  13. PHP_Timer->resourceUsage() C:\Users\lotus\projects\testing\laravel\vendor\brianium\paratest\src\ParaTest\Runners\PHPUnit\ResultPrinter.php:83

@brianium
Owner
brianium commented Jun 7, 2013

Interesting. Those strict standards errors should be easy enough to fix. PHP_Timer is being called in a similar manner to PHPUnit, so updating the timer call to the following should fix it

$timer = new PHP_Timer();
$timer->start();
$timer->resourceUsage();

This line is pretty intriguing:

Fatal error: Call to undefined method ParaTest\Runners\PHPUnit\ResultPrinter::timeSinceStartOfRequest() in C:\Users\lotus\projects\testing\laravel\vendor\phpunit\php-timer\PHP\Timer.php on line 150

As that method has never existed on the ResultPrinter in ParaTest. I wonder if this could be an issue with a global installation.

@brianium
Owner
brianium commented Jun 7, 2013

What version of PHP are you using?

@dbaltas
Collaborator
dbaltas commented Jun 7, 2013

The 'TestCase not found' may be related with loading the bootstrap. In 0.4.4 you have to specify the test bootstrap file as a command line argument paratest --bootstrap \path\to\bootstrap where in dev-master the bootstrap is loaded from phpunit.xml if set.

@isimmons
isimmons commented Jun 7, 2013

@dbaltas yeah --bootstrap argument resolved the TestClass not found issue.

@brianium php 5.4.11
Now that I'm not getting the TestClass not found problem, both global install and using local vendor/bin/paratest are throwing the above errors.

looking at timer.php it is calling $this->timeSinceStartOfRequest() not ResultPrinter::timeSinceStartOfRequest() so it has something to do with context of 'this' .

@isimmons

@brianium
Not sure what updates have been done to dev-master or laravel but since I was having issues with 0.4.4 and it had been a few days I removed and then re-installed paratest globally in C:\php\paratest using dev-master and it is working perfectly with the example laravel test plus a couple of my own simple sample tests.

Well it's lacking color but I won't complain since it is working. Any recent updates you know of that would have fixed this?

@brianium
Owner

We recently addressed a few issues in the tracker, and made significant improvements to windows compatibility. Glad to hear it is working for you! We will be tagging the next version very soon. Ok to close this then?

@isimmons

Yep, thanks a lot

@isimmons isimmons closed this Jun 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment