2017 © Pedro Peláez
 

library prophecy-phpunit

PhpUnit test case integrating the Prophecy mocking library

image

phpspec/prophecy-phpunit

PhpUnit test case integrating the Prophecy mocking library

  • Thursday, October 1, 2015
  • by Stof
  • Repository
  • 9 Watchers
  • 47 Stars
  • 207,912 Installations
  • PHP
  • 50 Dependents
  • 0 Suggesters
  • 10 Forks
  • 1 Open issues
  • 4 Versions
  • 2 % Grown

The README.md

Prophecy

Build Status, (*1)

Prophecy PhpUnit integrates the Prophecy mocking library with PHPUnit to provide an easier mocking in your testsuite., (*2)

Installation

Prerequisites

Prophecy PhpUnit requires PHP 7.3 or greater. Prophecy PhpUnit requires PHPUnit 9.1 or greater. Older versions of PHPUnit are providing the Prophecy integration themselves., (*3)

Setup through composer

composer require --dev phpspec/prophecy-phpunit

You can read more about Composer on its official webpage., (*4)

How to use it

The trait ProphecyTrait provides a method prophesize($classOrInterface = null) to use Prophecy. For the usage of the Prophecy doubles, please refer to the Prophecy documentation., (*5)

Below is a usage example:, (*6)

<?php

namespace App;

use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use App\Security\Hasher;
use App\Entity\User;

class UserTest extends TestCase
{
    use ProphecyTrait;

    public function testPasswordHashing()
    {
        $hasher = $this->prophesize(Hasher::class);
        $user   = new User($hasher->reveal());

        $hasher->generateHash($user, 'qwerty')->willReturn('hashed_pass');

        $user->setPassword('qwerty');

        $this->assertEquals('hashed_pass', $user->getPassword());
    }
}

The Versions

01/10 2015

dev-master

9999999-dev http://phpspec.net

PhpUnit test case integrating the Prophecy mocking library

  Sources   Download

MIT

The Requires

 

phpunit prophecy

09/02 2015

v1.1.0

1.1.0.0 http://phpspec.net

PhpUnit test case integrating the Prophecy mocking library

  Sources   Download

MIT

The Requires

 

phpunit prophecy

04/03 2014

v1.0.1

1.0.1.0 http://phpspec.org

PhpUnit test case integrating the Prophecy mocking library

  Sources   Download

MIT

The Requires

 

phpunit prophecy

04/07 2013

v1.0.0

1.0.0.0 http://phpspec.org

PhpUnit test case integrating the Prophecy mocking library

  Sources   Download

MIT

The Requires

 

phpunit prophecy