Open menu icon N-ARY CIRCLED PLUS OPERATOR

atoum/prophecy-extension Build Status

atoum has great stubbing/mocking system. If you prefer using prophecy, you can do it using this extension.

Example

Here is an example of how to create and use a stub using prophecy, in atoum :

<?php

namespace
{
  class foo
  {
    public function bar()
    {
      return '1';
    }
  }
}

namespace tests\units
{
  use mageekguy\atoum;

  class foo extends atoum\test
  {
    public function testBar()
    {
      $this
          ->given(
              $foo = $this
                  ->prophet
                  ->prophesize('foo')
                  ->bar()->willReturn('2')
                  ->reveal()
          )
          ->string($foo->bar())
            ->isEqualTo('2')
      ;
    }
  }
}

Install it

Install extension using composer:

composer config minimum-stability dev
composer config prefer-stable true
composer config repositories.atoumProphecy vcs https://github.com/atoum/prophecy-extension
composer require --dev atoum/prophecy-extension

Enable the extension using atoum configuration file:

<?php

// .atoum.php

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

use mageekguy\atoum\prophecy;

$extension = new prophecy\extension($script);

$extension->addToRunner($runner);

Documentation

The Prophecy\Prophet object will be available in your tests via the prophet attribute.

For usage on how to use it, you can read Prophecy's documentation.

Links

License

atoum prophecy-extension is released under the BSD-3-Clause License. See the bundled LICENSE file for details.

atoum