Pressroom template verwijderd, website naar root van repo

This commit is contained in:
2020-03-22 15:30:52 +01:00
parent 2cb6a77425
commit f3d1c41e91
7620 changed files with 0 additions and 186900 deletions

View File

@@ -0,0 +1,96 @@
<?php
namespace spec\Prophecy\Promise;
use PhpSpec\ObjectBehavior;
use Prophecy\Prophecy\MethodProphecy;
use Prophecy\Prophecy\ObjectProphecy;
class CallbackPromiseSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('get_class');
}
function it_is_promise()
{
$this->shouldBeAnInstanceOf('Prophecy\Promise\PromiseInterface');
}
function it_should_execute_closure_callback(ObjectProphecy $object, MethodProphecy $method)
{
$firstArgumentCallback = function ($args) {
return $args[0];
};
$this->beConstructedWith($firstArgumentCallback);
$this->execute(array('one', 'two'), $object, $method)->shouldReturn('one');
}
function it_should_execute_static_array_callback(ObjectProphecy $object, MethodProphecy $method)
{
$firstArgumentCallback = array('spec\Prophecy\Promise\ClassCallback', 'staticCallbackMethod');
$this->beConstructedWith($firstArgumentCallback);
$this->execute(array('one', 'two'), $object, $method)->shouldReturn('one');
}
function it_should_execute_instance_array_callback(ObjectProphecy $object, MethodProphecy $method)
{
$class = new ClassCallback();
$firstArgumentCallback = array($class, 'callbackMethod');
$this->beConstructedWith($firstArgumentCallback);
$this->execute(array('one', 'two'), $object, $method)->shouldReturn('one');
}
function it_should_execute_string_function_callback(ObjectProphecy $object, MethodProphecy $method)
{
$firstArgumentCallback = 'spec\Prophecy\Promise\functionCallbackFirstArgument';
$this->beConstructedWith($firstArgumentCallback);
$this->execute(array('one', 'two'), $object, $method)->shouldReturn('one');
}
}
/**
* Class used to test callbackpromise
*
* @param array
* @return string
*/
class ClassCallback
{
/**
* @param array $args
*/
function callbackMethod($args)
{
return $args[0];
}
/**
* @param array $args
*/
static function staticCallbackMethod($args)
{
return $args[0];
}
}
/**
* Callback function used to test callbackpromise
*
* @param array
* @return string
*/
function functionCallbackFirstArgument($args)
{
return $args[0];
}

View File

@@ -0,0 +1,31 @@
<?php
namespace spec\Prophecy\Promise;
use PhpSpec\ObjectBehavior;
use Prophecy\Prophecy\MethodProphecy;
use Prophecy\Prophecy\ObjectProphecy;
class ReturnArgumentPromiseSpec extends ObjectBehavior
{
function it_is_promise()
{
$this->shouldBeAnInstanceOf('Prophecy\Promise\PromiseInterface');
}
function it_should_return_first_argument_if_provided(ObjectProphecy $object, MethodProphecy $method)
{
$this->execute(array('one', 'two'), $object, $method)->shouldReturn('one');
}
function it_should_return_null_if_no_arguments_provided(ObjectProphecy $object, MethodProphecy $method)
{
$this->execute(array(), $object, $method)->shouldReturn(null);
}
function it_should_return_nth_argument_if_provided(ObjectProphecy $object, MethodProphecy $method)
{
$this->beConstructedWith(1);
$this->execute(array('one', 'two'), $object, $method)->shouldReturn('two');
}
}

View File

@@ -0,0 +1,49 @@
<?php
namespace spec\Prophecy\Promise;
use PhpSpec\ObjectBehavior;
use Prophecy\Prophecy\MethodProphecy;
use Prophecy\Prophecy\ObjectProphecy;
class ReturnPromiseSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith(array(42));
}
function it_is_promise()
{
$this->shouldBeAnInstanceOf('Prophecy\Promise\PromiseInterface');
}
function it_returns_value_it_was_constructed_with(ObjectProphecy $object, MethodProphecy $method)
{
$this->execute(array(), $object, $method)->shouldReturn(42);
}
function it_always_returns_last_value_left_in_the_return_values(ObjectProphecy $object, MethodProphecy $method)
{
$this->execute(array(), $object, $method)->shouldReturn(42);
$this->execute(array(), $object, $method)->shouldReturn(42);
}
function it_consequently_returns_multiple_values_it_was_constructed_with(
ObjectProphecy $object,
MethodProphecy $method
) {
$this->beConstructedWith(array(42, 24, 12));
$this->execute(array(), $object, $method)->shouldReturn(42);
$this->execute(array(), $object, $method)->shouldReturn(24);
$this->execute(array(), $object, $method)->shouldReturn(12);
}
function it_returns_null_if_constructed_with_empty_array(ObjectProphecy $object, MethodProphecy $method)
{
$this->beConstructedWith(array());
$this->execute(array(), $object, $method)->shouldReturn(null);
}
}

View File

@@ -0,0 +1,92 @@
<?php
namespace spec\Prophecy\Promise;
use PhpSpec\Exception\Example\SkippingException;
use PhpSpec\ObjectBehavior;
use Prophecy\Prophecy\MethodProphecy;
use Prophecy\Prophecy\ObjectProphecy;
class ThrowPromiseSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('RuntimeException');
}
function it_is_promise()
{
$this->shouldBeAnInstanceOf('Prophecy\Promise\PromiseInterface');
}
function it_instantiates_and_throws_exception_from_provided_classname(ObjectProphecy $object, MethodProphecy $method)
{
$this->beConstructedWith('InvalidArgumentException');
$this->shouldThrow('InvalidArgumentException')
->duringExecute(array(), $object, $method);
}
function it_instantiates_exceptions_with_required_arguments(ObjectProphecy $object, MethodProphecy $method)
{
$this->beConstructedWith('spec\Prophecy\Promise\RequiredArgumentException');
$this->shouldThrow('spec\Prophecy\Promise\RequiredArgumentException')
->duringExecute(array(), $object, $method);
}
function it_throws_provided_exception(ObjectProphecy $object, MethodProphecy $method)
{
$this->beConstructedWith($exc = new \RuntimeException('Some exception'));
$this->shouldThrow($exc)->duringExecute(array(), $object, $method);
}
function it_throws_error_instances(ObjectProphecy $object, MethodProphecy $method)
{
if (!class_exists('\Error')) {
throw new SkippingException('The class Error, introduced in PHP 7, does not exist');
}
$this->beConstructedWith($exc = new \Error('Error exception'));
$this->shouldThrow($exc)->duringExecute(array(), $object, $method);
}
function it_throws_errors_by_class_name()
{
if (!class_exists('\Error')) {
throw new SkippingException('The class Error, introduced in PHP 7, does not exist');
}
$this->beConstructedWith('\Error');
$this->shouldNotThrow('Prophecy\Exception\InvalidArgumentException')->duringInstantiation();
}
function it_does_not_throw_something_that_is_not_throwable_by_class_name()
{
$this->beConstructedWith('\stdClass');
$this->shouldThrow('Prophecy\Exception\InvalidArgumentException')->duringInstantiation();
}
function it_does_not_throw_something_that_is_not_throwable_by_instance()
{
$this->beConstructedWith(new \stdClass());
$this->shouldThrow('Prophecy\Exception\InvalidArgumentException')->duringInstantiation();
}
function it_throws_an_exception_by_class_name()
{
$this->beConstructedWith('\Exception');
$this->shouldNotThrow('Prophecy\Exception\InvalidArgumentException')->duringInstantiation();
}
}
class RequiredArgumentException extends \Exception
{
final public function __construct($message, $code) {}
}