BossaConsulting / phpspec2-expect

Helper that decorates any SUS with a PhpSpec lazy object wrapper
MIT License
75 stars 34 forks source link

Provided a custom implementation of Wrapper #10

Closed jakzal closed 10 years ago

jakzal commented 10 years ago

To make sure that wrapper creates a custom Subject implementation, as a quick fix I provided a custom Wrapper.

The Wrapper is basically copied over so I treat it as a temporary implementation.

Expressions like the following one started to fail with a recent PhpSpec update:

<?php

require_once __DIR__.'/vendor/autoload.php';

class User
{
    public function getName()
    {
        return 'Kuba';
    }
}

expect(new User())->getName()->toBe('Kuba');
PHP Fatal error:  Uncaught exception 'ReflectionException' with message 'Class  does not exist' in /home/jzalas/Projects/phpspec2-expect/vendor/phpspec/phpspec/src/PhpSpec/Util/Instantiator.php:17
Stack trace:
#0 /home/jzalas/Projects/phpspec2-expect/vendor/phpspec/phpspec/src/PhpSpec/Util/Instantiator.php(17): ReflectionClass->__construct('')
#1 /home/jzalas/Projects/phpspec2-expect/vendor/phpspec/phpspec/src/PhpSpec/Util/Instantiator.php(12): PhpSpec\Util\Instantiator->createSerializedObject(NULL)
#2 /home/jzalas/Projects/phpspec2-expect/vendor/phpspec/phpspec/src/PhpSpec/Exception/ExceptionFactory.php(21): PhpSpec\Util\Instantiator->instantiate(NULL)
#3 /home/jzalas/Projects/phpspec2-expect/vendor/phpspec/phpspec/src/PhpSpec/Wrapper/Subject/Caller.php(213): PhpSpec\Exception\ExceptionFactory->methodNotFound(NULL, 'toBe', Array)
#4 /home/jzalas/Projects/phpspec2-expect/vendor/phpspec/phpspec/src/PhpSpec/Wrapper/Subject/Caller.php(53): PhpSpec\Wrapper\Subject\Caller->methodNotFound('toBe', Array)
#5 /home/jzalas/Projects/phps in /home/jzalas/Projects/phpspec2-expect/vendor/phpspec/phpspec/src/PhpSpec/Util/Instantiator.php on line 17