Skip to content
This repository has been archived by the owner on Jul 8, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/0.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzatron committed Oct 20, 2015
2 parents 5970446 + f6a4302 commit 15be272
Show file tree
Hide file tree
Showing 17 changed files with 282 additions and 270 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Phony changelog

## 0.5.0 (2015-10-20)

- **[BC BREAK]** Removed `fullMock()`, changed `mock()` to create full mocks,
and added `partialMock()` for creating partial mocks ([#73]).

[#73]: https://github.com/eloquent/phony/issues/73

## 0.4.0 (2015-10-20)

- **[IMPROVED]** Implemented new 'equal to' matcher ([#70] - thanks [@jmalloc]).
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

*Mocks, stubs, and spies for PHP.*

[![The most recent stable version is 0.4.0][version-image]][semantic versioning]
[![The most recent stable version is 0.5.0][version-image]][semantic versioning]
[![Current build status image][build-image]][current build status]
[![Current coverage status image][coverage-image]][current coverage status]

Expand All @@ -11,7 +11,7 @@
[coverage-image]: https://img.shields.io/codecov/c/github/eloquent/phony/develop.svg?style=flat-square "Current test coverage for the develop branch"
[current coverage status]: https://codecov.io/github/eloquent/phony
[semantic versioning]: http://semver.org/
[version-image]: http://img.shields.io/:semver-0.4.0-yellow.svg?style=flat-square "This project uses semantic versioning"
[version-image]: http://img.shields.io/:semver-0.5.0-yellow.svg?style=flat-square "This project uses semantic versioning"

## Installation and documentation

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},
"extra": {
"branch-alias": {
"dev-develop": "0.5.x-dev"
"dev-develop": "0.6.x-dev"
}
}
}
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 22 additions & 17 deletions src/Facade/AbstractFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,49 +55,54 @@ public static function mockBuilder(
}

/**
* Create a new mock.
* Create a new full mock.
*
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
* @param ArgumentsInterface|array|null $arguments The constructor arguments, or null to bypass the constructor.
* @param array|object|null $definition The definition.
* @param string|null $className The class name.
*
* @return InstanceStubbingProxyInterface A stubbing proxy around the new mock.
*/
public static function mock(
$types = null,
$arguments = null,
$definition = null,
$className = null
) {
if (func_num_args() > 1) {
$mock = static::driver()->mockBuilderFactory()
->createMock($types, $arguments, $definition, $className);
} else {
$mock = static::driver()->mockBuilderFactory()->createMock($types);
}

return static::on($mock);
return static::on(
static::driver()->mockBuilderFactory()
->createFullMock($types, $definition, $className)
);
}

/**
* Create a new full mock.
* Create a new partial mock.
*
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
* @param ArgumentsInterface|array|null $arguments The constructor arguments, or null to bypass the constructor.
* @param array|object|null $definition The definition.
* @param string|null $className The class name.
*
* @return InstanceStubbingProxyInterface A stubbing proxy around the new mock.
*/
public static function fullMock(
public static function partialMock(
$types = null,
$arguments = null,
$definition = null,
$className = null
) {
return static::on(
static::driver()->mockBuilderFactory()
->createFullMock($types, $definition, $className)
);
if (func_num_args() > 1) {
$mock = static::driver()->mockBuilderFactory()->createPartialMock(
$types,
$arguments,
$definition,
$className
);
} else {
$mock = static::driver()->mockBuilderFactory()
->createPartialMock($types);
}

return static::on($mock);
}

/**
Expand Down
26 changes: 13 additions & 13 deletions src/Mock/Builder/Factory/MockBuilderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,44 +108,44 @@ public function create(
}

/**
* Create a new mock.
* Create a new full mock.
*
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
* @param ArgumentsInterface|array|null $arguments The constructor arguments, or null to bypass the constructor.
* @param array|object|null $definition The definition.
* @param string|null $className The class name.
*
* @return MockInterface The mock.
*/
public function createMock(
public function createFullMock(
$types = null,
$arguments = null,
$definition = null,
$className = null
) {
if (null !== $arguments || func_num_args() < 2) {
$arguments = Arguments::adapt($arguments);
}

return $this->create($types, $definition, $className)
->createWith($arguments);
return $this->create($types, $definition, $className)->full();
}

/**
* Create a new full mock.
* Create a new partial mock.
*
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
* @param ArgumentsInterface|array|null $arguments The constructor arguments, or null to bypass the constructor.
* @param array|object|null $definition The definition.
* @param string|null $className The class name.
*
* @return MockInterface The mock.
*/
public function createFullMock(
public function createPartialMock(
$types = null,
$arguments = null,
$definition = null,
$className = null
) {
return $this->create($types, $definition, $className)->full();
if (null !== $arguments || func_num_args() < 2) {
$arguments = Arguments::adapt($arguments);
}

return $this->create($types, $definition, $className)
->createWith($arguments);
}

private static $instance;
Expand Down
12 changes: 6 additions & 6 deletions src/Mock/Builder/Factory/MockBuilderFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,33 @@ public function create(
);

/**
* Create a new mock.
* Create a new full mock.
*
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
* @param ArgumentsInterface|array|null $arguments The constructor arguments, or null to bypass the constructor.
* @param array|object|null $definition The definition.
* @param string|null $className The class name.
*
* @return MockInterface The mock.
*/
public function createMock(
public function createFullMock(
$types = null,
$arguments = null,
$definition = null,
$className = null
);

/**
* Create a new full mock.
* Create a new partial mock.
*
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
* @param ArgumentsInterface|array|null $arguments The constructor arguments, or null to bypass the constructor.
* @param array|object|null $definition The definition.
* @param string|null $className The class name.
*
* @return MockInterface The mock.
*/
public function createFullMock(
public function createPartialMock(
$types = null,
$arguments = null,
$definition = null,
$className = null
);
Expand Down
42 changes: 21 additions & 21 deletions src/Pho/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,24 @@ function mockBuilder($types = null, $definition = null, $className = null)
}

/**
* Create a new mock.
* Create a new full mock.
*
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
* @param array|object|null $definition The definition.
* @param string|null $className The class name.
*
* @return InstanceStubbingProxyInterface A stubbing proxy around the new mock.
*/
function mock($types = null, $definition = null, $className = null)
{
return on(
PhoFacadeDriver::instance()->mockBuilderFactory()
->createFullMock($types, $definition, $className)
);
}

/**
* Create a new partial mock.
*
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
* @param ArgumentsInterface|array|null $arguments The constructor arguments, or null to bypass the constructor.
Expand All @@ -54,40 +71,23 @@ function mockBuilder($types = null, $definition = null, $className = null)
*
* @return InstanceStubbingProxyInterface A stubbing proxy around the new mock.
*/
function mock(
function partialMock(
$types = null,
$arguments = null,
$definition = null,
$className = null
) {
if (func_num_args() > 1) {
$mock = PhoFacadeDriver::instance()->mockBuilderFactory()
->createMock($types, $arguments, $definition, $className);
->createPartialMock($types, $arguments, $definition, $className);
} else {
$mock = PhoFacadeDriver::instance()->mockBuilderFactory()
->createMock($types);
->createPartialMock($types);
}

return on($mock);
}

/**
* Create a new full mock.
*
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
* @param array|object|null $definition The definition.
* @param string|null $className The class name.
*
* @return InstanceStubbingProxyInterface A stubbing proxy around the new mock.
*/
function fullMock($types = null, $definition = null, $className = null)
{
return on(
PhoFacadeDriver::instance()->mockBuilderFactory()
->createFullMock($types, $definition, $className)
);
}

/**
* Create a new stubbing proxy.
*
Expand Down
42 changes: 21 additions & 21 deletions src/Phpunit/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,24 @@ function mockBuilder($types = null, $definition = null, $className = null)
}

/**
* Create a new mock.
* Create a new full mock.
*
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
* @param array|object|null $definition The definition.
* @param string|null $className The class name.
*
* @return InstanceStubbingProxyInterface A stubbing proxy around the new mock.
*/
function mock($types = null, $definition = null, $className = null)
{
return on(
PhpunitFacadeDriver::instance()->mockBuilderFactory()
->createFullMock($types, $definition, $className)
);
}

/**
* Create a new partial mock.
*
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
* @param ArgumentsInterface|array|null $arguments The constructor arguments, or null to bypass the constructor.
Expand All @@ -54,40 +71,23 @@ function mockBuilder($types = null, $definition = null, $className = null)
*
* @return InstanceStubbingProxyInterface A stubbing proxy around the new mock.
*/
function mock(
function partialMock(
$types = null,
$arguments = null,
$definition = null,
$className = null
) {
if (func_num_args() > 1) {
$mock = PhpunitFacadeDriver::instance()->mockBuilderFactory()
->createMock($types, $arguments, $definition, $className);
->createPartialMock($types, $arguments, $definition, $className);
} else {
$mock = PhpunitFacadeDriver::instance()->mockBuilderFactory()
->createMock($types);
->createPartialMock($types);
}

return on($mock);
}

/**
* Create a new full mock.
*
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
* @param array|object|null $definition The definition.
* @param string|null $className The class name.
*
* @return InstanceStubbingProxyInterface A stubbing proxy around the new mock.
*/
function fullMock($types = null, $definition = null, $className = null)
{
return on(
PhpunitFacadeDriver::instance()->mockBuilderFactory()
->createFullMock($types, $definition, $className)
);
}

/**
* Create a new stubbing proxy.
*
Expand Down
Loading

0 comments on commit 15be272

Please sign in to comment.