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

Commit 15be272

Browse files
committed
Merge branch 'release/0.5.0'
2 parents 5970446 + f6a4302 commit 15be272

File tree

17 files changed

+282
-270
lines changed

17 files changed

+282
-270
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Phony changelog
22

3+
## 0.5.0 (2015-10-20)
4+
5+
- **[BC BREAK]** Removed `fullMock()`, changed `mock()` to create full mocks,
6+
and added `partialMock()` for creating partial mocks ([#73]).
7+
8+
[#73]: https://github.com/eloquent/phony/issues/73
9+
310
## 0.4.0 (2015-10-20)
411

512
- **[IMPROVED]** Implemented new 'equal to' matcher ([#70] - thanks [@jmalloc]).

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
*Mocks, stubs, and spies for PHP.*
44

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

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

1616
## Installation and documentation
1717

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
},
5151
"extra": {
5252
"branch-alias": {
53-
"dev-develop": "0.5.x-dev"
53+
"dev-develop": "0.6.x-dev"
5454
}
5555
}
5656
}

composer.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Facade/AbstractFacade.php

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,49 +55,54 @@ public static function mockBuilder(
5555
}
5656

5757
/**
58-
* Create a new mock.
58+
* Create a new full mock.
5959
*
6060
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
61-
* @param ArgumentsInterface|array|null $arguments The constructor arguments, or null to bypass the constructor.
6261
* @param array|object|null $definition The definition.
6362
* @param string|null $className The class name.
6463
*
6564
* @return InstanceStubbingProxyInterface A stubbing proxy around the new mock.
6665
*/
6766
public static function mock(
6867
$types = null,
69-
$arguments = null,
7068
$definition = null,
7169
$className = null
7270
) {
73-
if (func_num_args() > 1) {
74-
$mock = static::driver()->mockBuilderFactory()
75-
->createMock($types, $arguments, $definition, $className);
76-
} else {
77-
$mock = static::driver()->mockBuilderFactory()->createMock($types);
78-
}
79-
80-
return static::on($mock);
71+
return static::on(
72+
static::driver()->mockBuilderFactory()
73+
->createFullMock($types, $definition, $className)
74+
);
8175
}
8276

8377
/**
84-
* Create a new full mock.
78+
* Create a new partial mock.
8579
*
8680
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
81+
* @param ArgumentsInterface|array|null $arguments The constructor arguments, or null to bypass the constructor.
8782
* @param array|object|null $definition The definition.
8883
* @param string|null $className The class name.
8984
*
9085
* @return InstanceStubbingProxyInterface A stubbing proxy around the new mock.
9186
*/
92-
public static function fullMock(
87+
public static function partialMock(
9388
$types = null,
89+
$arguments = null,
9490
$definition = null,
9591
$className = null
9692
) {
97-
return static::on(
98-
static::driver()->mockBuilderFactory()
99-
->createFullMock($types, $definition, $className)
100-
);
93+
if (func_num_args() > 1) {
94+
$mock = static::driver()->mockBuilderFactory()->createPartialMock(
95+
$types,
96+
$arguments,
97+
$definition,
98+
$className
99+
);
100+
} else {
101+
$mock = static::driver()->mockBuilderFactory()
102+
->createPartialMock($types);
103+
}
104+
105+
return static::on($mock);
101106
}
102107

103108
/**

src/Mock/Builder/Factory/MockBuilderFactory.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,44 +108,44 @@ public function create(
108108
}
109109

110110
/**
111-
* Create a new mock.
111+
* Create a new full mock.
112112
*
113113
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
114-
* @param ArgumentsInterface|array|null $arguments The constructor arguments, or null to bypass the constructor.
115114
* @param array|object|null $definition The definition.
116115
* @param string|null $className The class name.
117116
*
118117
* @return MockInterface The mock.
119118
*/
120-
public function createMock(
119+
public function createFullMock(
121120
$types = null,
122-
$arguments = null,
123121
$definition = null,
124122
$className = null
125123
) {
126-
if (null !== $arguments || func_num_args() < 2) {
127-
$arguments = Arguments::adapt($arguments);
128-
}
129-
130-
return $this->create($types, $definition, $className)
131-
->createWith($arguments);
124+
return $this->create($types, $definition, $className)->full();
132125
}
133126

134127
/**
135-
* Create a new full mock.
128+
* Create a new partial mock.
136129
*
137130
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
131+
* @param ArgumentsInterface|array|null $arguments The constructor arguments, or null to bypass the constructor.
138132
* @param array|object|null $definition The definition.
139133
* @param string|null $className The class name.
140134
*
141135
* @return MockInterface The mock.
142136
*/
143-
public function createFullMock(
137+
public function createPartialMock(
144138
$types = null,
139+
$arguments = null,
145140
$definition = null,
146141
$className = null
147142
) {
148-
return $this->create($types, $definition, $className)->full();
143+
if (null !== $arguments || func_num_args() < 2) {
144+
$arguments = Arguments::adapt($arguments);
145+
}
146+
147+
return $this->create($types, $definition, $className)
148+
->createWith($arguments);
149149
}
150150

151151
private static $instance;

src/Mock/Builder/Factory/MockBuilderFactoryInterface.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,33 +37,33 @@ public function create(
3737
);
3838

3939
/**
40-
* Create a new mock.
40+
* Create a new full mock.
4141
*
4242
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
43-
* @param ArgumentsInterface|array|null $arguments The constructor arguments, or null to bypass the constructor.
4443
* @param array|object|null $definition The definition.
4544
* @param string|null $className The class name.
4645
*
4746
* @return MockInterface The mock.
4847
*/
49-
public function createMock(
48+
public function createFullMock(
5049
$types = null,
51-
$arguments = null,
5250
$definition = null,
5351
$className = null
5452
);
5553

5654
/**
57-
* Create a new full mock.
55+
* Create a new partial mock.
5856
*
5957
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
58+
* @param ArgumentsInterface|array|null $arguments The constructor arguments, or null to bypass the constructor.
6059
* @param array|object|null $definition The definition.
6160
* @param string|null $className The class name.
6261
*
6362
* @return MockInterface The mock.
6463
*/
65-
public function createFullMock(
64+
public function createPartialMock(
6665
$types = null,
66+
$arguments = null,
6767
$definition = null,
6868
$className = null
6969
);

src/Pho/functions.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,24 @@ function mockBuilder($types = null, $definition = null, $className = null)
4545
}
4646

4747
/**
48-
* Create a new mock.
48+
* Create a new full mock.
49+
*
50+
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
51+
* @param array|object|null $definition The definition.
52+
* @param string|null $className The class name.
53+
*
54+
* @return InstanceStubbingProxyInterface A stubbing proxy around the new mock.
55+
*/
56+
function mock($types = null, $definition = null, $className = null)
57+
{
58+
return on(
59+
PhoFacadeDriver::instance()->mockBuilderFactory()
60+
->createFullMock($types, $definition, $className)
61+
);
62+
}
63+
64+
/**
65+
* Create a new partial mock.
4966
*
5067
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
5168
* @param ArgumentsInterface|array|null $arguments The constructor arguments, or null to bypass the constructor.
@@ -54,40 +71,23 @@ function mockBuilder($types = null, $definition = null, $className = null)
5471
*
5572
* @return InstanceStubbingProxyInterface A stubbing proxy around the new mock.
5673
*/
57-
function mock(
74+
function partialMock(
5875
$types = null,
5976
$arguments = null,
6077
$definition = null,
6178
$className = null
6279
) {
6380
if (func_num_args() > 1) {
6481
$mock = PhoFacadeDriver::instance()->mockBuilderFactory()
65-
->createMock($types, $arguments, $definition, $className);
82+
->createPartialMock($types, $arguments, $definition, $className);
6683
} else {
6784
$mock = PhoFacadeDriver::instance()->mockBuilderFactory()
68-
->createMock($types);
85+
->createPartialMock($types);
6986
}
7087

7188
return on($mock);
7289
}
7390

74-
/**
75-
* Create a new full mock.
76-
*
77-
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
78-
* @param array|object|null $definition The definition.
79-
* @param string|null $className The class name.
80-
*
81-
* @return InstanceStubbingProxyInterface A stubbing proxy around the new mock.
82-
*/
83-
function fullMock($types = null, $definition = null, $className = null)
84-
{
85-
return on(
86-
PhoFacadeDriver::instance()->mockBuilderFactory()
87-
->createFullMock($types, $definition, $className)
88-
);
89-
}
90-
9191
/**
9292
* Create a new stubbing proxy.
9393
*

src/Phpunit/functions.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,24 @@ function mockBuilder($types = null, $definition = null, $className = null)
4545
}
4646

4747
/**
48-
* Create a new mock.
48+
* Create a new full mock.
49+
*
50+
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
51+
* @param array|object|null $definition The definition.
52+
* @param string|null $className The class name.
53+
*
54+
* @return InstanceStubbingProxyInterface A stubbing proxy around the new mock.
55+
*/
56+
function mock($types = null, $definition = null, $className = null)
57+
{
58+
return on(
59+
PhpunitFacadeDriver::instance()->mockBuilderFactory()
60+
->createFullMock($types, $definition, $className)
61+
);
62+
}
63+
64+
/**
65+
* Create a new partial mock.
4966
*
5067
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
5168
* @param ArgumentsInterface|array|null $arguments The constructor arguments, or null to bypass the constructor.
@@ -54,40 +71,23 @@ function mockBuilder($types = null, $definition = null, $className = null)
5471
*
5572
* @return InstanceStubbingProxyInterface A stubbing proxy around the new mock.
5673
*/
57-
function mock(
74+
function partialMock(
5875
$types = null,
5976
$arguments = null,
6077
$definition = null,
6178
$className = null
6279
) {
6380
if (func_num_args() > 1) {
6481
$mock = PhpunitFacadeDriver::instance()->mockBuilderFactory()
65-
->createMock($types, $arguments, $definition, $className);
82+
->createPartialMock($types, $arguments, $definition, $className);
6683
} else {
6784
$mock = PhpunitFacadeDriver::instance()->mockBuilderFactory()
68-
->createMock($types);
85+
->createPartialMock($types);
6986
}
7087

7188
return on($mock);
7289
}
7390

74-
/**
75-
* Create a new full mock.
76-
*
77-
* @param string|ReflectionClass|MockBuilderInterface|array<string|ReflectionClass|MockBuilderInterface>|null $types The types to mock.
78-
* @param array|object|null $definition The definition.
79-
* @param string|null $className The class name.
80-
*
81-
* @return InstanceStubbingProxyInterface A stubbing proxy around the new mock.
82-
*/
83-
function fullMock($types = null, $definition = null, $className = null)
84-
{
85-
return on(
86-
PhpunitFacadeDriver::instance()->mockBuilderFactory()
87-
->createFullMock($types, $definition, $className)
88-
);
89-
}
90-
9191
/**
9292
* Create a new stubbing proxy.
9393
*

0 commit comments

Comments
 (0)