Вход Регистрация
Файл: src/vendor/phpspec/prophecy/spec/Prophecy/Doubler/LazyDoubleSpec.php
Строк: 106
<?php

namespace specProphecyDoubler;

use 
PhpSpecObjectBehavior;

class 
LazyDoubleSpec extends ObjectBehavior
{
    
/**
     * @param ProphecyDoublerDoubler $doubler
     */
    
function let($doubler)
    {
        
$this->beConstructedWith($doubler);
    }

    
/**
     * @param ProphecyProphecyProphecySubjectInterface $double
     */
    
function it_returns_anonymous_double_instance_by_default($doubler$double)
    {
        
$doubler->double(null, array())->willReturn($double);

        
$this->getInstance()->shouldReturn($double);
    }

    
/**
     * @param ProphecyProphecyProphecySubjectInterface $double
     * @param ReflectionClass                            $class
     */
    
function it_returns_class_double_instance_if_set($doubler$double$class)
    {
        
$doubler->double($class, array())->willReturn($double);

        
$this->setParentClass($class);

        
$this->getInstance()->shouldReturn($double);
    }

    
/**
     * @param ProphecyProphecyProphecySubjectInterface $double1
     * @param ProphecyProphecyProphecySubjectInterface $double2
     */
    
function it_returns_same_double_instance_if_called_2_times(
        
$doubler$double1$double2
    
)
    {
        
$doubler->double(null, array())->willReturn($double1);
        
$doubler->double(null, array())->willReturn($double2);

        
$this->getInstance()->shouldReturn($double2);
        
$this->getInstance()->shouldReturn($double2);
    }

    function 
its_setParentClass_throws_ClassNotFoundException_if_class_not_found()
    {
        
$this->shouldThrow('ProphecyExceptionDoublerClassNotFoundException')
            ->
duringSetParentClass('SomeUnexistingClass');
    }

    
/**
     * @param ProphecyProphecyProphecySubjectInterface $double
     */
    
function its_setParentClass_throws_exception_if_prophecy_is_already_created(
        
$doubler$double
    
)
    {
        
$doubler->double(null, array())->willReturn($double);

        
$this->getInstance();

        
$this->shouldThrow('ProphecyExceptionDoublerDoubleException')
            ->
duringSetParentClass('stdClass');
    }

    function 
its_addInterface_throws_InterfaceNotFoundException_if_no_interface_found()
    {
        
$this->shouldThrow('ProphecyExceptionDoublerInterfaceNotFoundException')
            ->
duringAddInterface('SomeUnexistingInterface');
    }

    
/**
     * @param ProphecyProphecyProphecySubjectInterface $double
     */
    
function its_addInterface_throws_exception_if_prophecy_is_already_created(
        
$doubler$double
    
)
    {
        
$doubler->double(null, array())->willReturn($double);

        
$this->getInstance();

        
$this->shouldThrow('ProphecyExceptionDoublerDoubleException')
            ->
duringAddInterface('ArrayAccess');
    }
}
Онлайн: 6
Реклама