Skip to content

Commit 515d9e6

Browse files
committed
Merge remote-tracking branch 'origin/master' into hotfix/double-mock
2 parents d20dffe + 291569e commit 515d9e6

15 files changed

+176
-69
lines changed
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: "Check Coding Standards"
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
jobs:
8+
coding-standards:
9+
name: "Check Coding Standards"
10+
11+
runs-on: "ubuntu-latest"
12+
13+
steps:
14+
- name: "Checkout"
15+
uses: "actions/checkout@v2"
16+
17+
- name: "Setup PHP"
18+
uses: "shivammathur/setup-php@v2"
19+
with:
20+
php-version: "7.4"
21+
tools: composer:v2, cs2pr
22+
23+
- name: "Install dependencies"
24+
run: "composer install --no-interaction --no-progress --no-suggest"
25+
26+
- name: "Run phpcs"
27+
run: vendor/bin/phpcs -q --report=checkstyle | cs2pr

.github/workflows/phpmd.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: "Check phpmd"
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
jobs:
8+
coding-standards:
9+
name: "Check phpmd"
10+
11+
runs-on: "ubuntu-latest"
12+
13+
steps:
14+
- name: "Checkout"
15+
uses: "actions/checkout@v2"
16+
17+
- name: "Setup PHP"
18+
uses: "shivammathur/setup-php@v2"
19+
with:
20+
php-version: "7.4"
21+
tools: composer:v2
22+
23+
- name: "Install dependencies"
24+
run: "composer require phpmd/phpmd --no-interaction --no-progress --no-suggest"
25+
26+
- name: "Run phpmd"
27+
run: vendor/bin/phpmd classes/ text cleancode,codesize,controversial,design,naming,unusedcode

.github/workflows/phpunit.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: "PHPUnit tests"
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
jobs:
8+
phpunit:
9+
name: PHPUnit tests on PHP ${{ matrix.php-version }}
10+
11+
runs-on: "ubuntu-latest"
12+
13+
strategy:
14+
matrix:
15+
php-version:
16+
- "7.2"
17+
- "7.3"
18+
- "7.4"
19+
- "8.0"
20+
21+
steps:
22+
- name: "Checkout"
23+
uses: "actions/checkout@v2"
24+
25+
- name: "Install PHP"
26+
uses: "shivammathur/setup-php@v2"
27+
with:
28+
coverage: "pcov"
29+
php-version: "${{ matrix.php-version }}"
30+
ini-values: memory_limit=-1
31+
tools: composer:v2
32+
33+
- name: "Cache dependencies"
34+
uses: "actions/cache@v2"
35+
with:
36+
path: |
37+
~/.composer/cache
38+
vendor
39+
key: "php-${{ matrix.php-version }}"
40+
restore-keys: "php-${{ matrix.php-version }}"
41+
42+
- name: "Install dependencies"
43+
run: "composer install --no-interaction --no-progress --no-suggest"
44+
45+
- name: "Tests"
46+
run: vendor/bin/phpunit

.github/workflows/test-flight.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: "Check test-flight"
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
jobs:
8+
coding-standards:
9+
name: "Check test-flight"
10+
11+
runs-on: "ubuntu-latest"
12+
13+
steps:
14+
- name: "Checkout"
15+
uses: "actions/checkout@v2"
16+
17+
- name: "Setup PHP"
18+
uses: "shivammathur/setup-php@v2"
19+
with:
20+
php-version: "7.4"
21+
tools: composer:v2
22+
ini-values: "zend.assertions=1"
23+
24+
- name: "Install dependencies"
25+
run: "composer require cundd/test-flight --no-interaction --no-progress --no-suggest"
26+
27+
- name: "Run test-flight"
28+
run: |
29+
vendor/bin/test-flight README.md
30+
vendor/bin/test-flight classes/

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.phpunit.result.cache
2+
/composer.lock
3+
/vendor/

.travis.yml

-40
This file was deleted.

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,3 @@ Responsable for this project is Markus Malkusch [email protected].
6161

6262
If you like this project and feel generous donate a few Bitcoins here:
6363
[1335STSwu9hST4vcMRppEPgENMHD2r1REK](bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK)
64-
65-
[![Build Status](https://travis-ci.org/php-mock/php-mock-prophecy.svg?branch=master)](https://travis-ci.org/php-mock/php-mock-prophecy)

classes/FunctionProphecy.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@
1717
*/
1818
final class FunctionProphecy implements ProphecyInterface
1919
{
20-
20+
2121
/**
2222
* @var Prophet The prophet.
2323
*/
2424
private $prophet;
25-
25+
2626
/**
2727
* @var string The namespace.
2828
*/
2929
private $namespace;
30-
30+
3131
/**
3232
* @var Revelation[] The delegated prophecies.
3333
*/
3434
private $revelations = [];
35-
35+
3636
/**
3737
* Sets the prophet.
3838
*
@@ -44,7 +44,7 @@ public function __construct($namespace, Prophet $prophet)
4444
$this->prophet = $prophet;
4545
$this->namespace = $namespace;
4646
}
47-
47+
4848
/**
4949
* Creates a new function prophecy using the specified function name
5050
* and arguments.
@@ -74,7 +74,7 @@ public function __call($functionName, array $arguments)
7474

7575
return $prophecy->__call(MockDelegateFunctionBuilder::METHOD, $arguments);
7676
}
77-
77+
7878
/**
7979
* Reveals the function prophecies.
8080
*

classes/PHPProphet.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Prophecy\Prophet;
88
use Prophecy\Prophecy\ProphecyInterface;
99
use Prophecy\Exception\Prediction\AggregateException;
10+
use ReflectionProperty;
1011

1112
/**
1213
* A Prophet for built-in PHP functions.
@@ -38,7 +39,7 @@ final class PHPProphet
3839
* @var Prophet The prophet.
3940
*/
4041
private $prophet;
41-
42+
4243
/**
4344
* Builds the prophet.
4445
*
@@ -49,12 +50,12 @@ public function __construct(Prophet $prophet = null)
4950
if (is_null($prophet)) {
5051
$prophet = new Prophet();
5152
}
52-
53+
5354
$revealer = new ReferencePreservingRevealer(self::getProperty($prophet, "revealer"));
5455
$util = self::getProperty($prophet, "util");
5556
$this->prophet = new Prophet($prophet->getDoubler(), $revealer, $util);
5657
}
57-
58+
5859
/**
5960
* Creates a new function prophecy for a given namespace.
6061
*
@@ -66,7 +67,7 @@ public function prophesize($namespace)
6667
{
6768
return new FunctionProphecy($namespace, $this->prophet);
6869
}
69-
70+
7071
/**
7172
* Checks all predictions defined by prophecies of this Prophet.
7273
*
@@ -80,7 +81,7 @@ public function checkPredictions()
8081
Mock::disableAll();
8182
$this->prophet->checkPredictions();
8283
}
83-
84+
8485
/**
8586
* Defines the function prophecy in the given namespace.
8687
*
@@ -109,7 +110,7 @@ public static function define($namespace, $name)
109110
->build()
110111
->define();
111112
}
112-
113+
113114
/**
114115
* Returns a private property of a prophet.
115116
*
@@ -120,7 +121,7 @@ public static function define($namespace, $name)
120121
*/
121122
private static function getProperty(Prophet $prophet, $property)
122123
{
123-
$reflection = new \ReflectionProperty($prophet, $property);
124+
$reflection = new ReflectionProperty($prophet, $property);
124125
$reflection->setAccessible(true);
125126
return $reflection->getValue($prophet);
126127
}

classes/ReferencePreservingRevealer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
*/
1616
final class ReferencePreservingRevealer implements RevealerInterface
1717
{
18-
18+
1919
/**
2020
* @var RevealerInterface The subject.
2121
*/
2222
private $revealer;
23-
23+
2424
/**
2525
* Sets the subject.
2626
*

classes/Revelation.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,23 @@ final class Revelation implements ProphecyInterface
1818
{
1919

2020
/**
21+
* @internal
2122
* @var string The function namespace.
2223
*/
2324
public $namespace;
2425

2526
/**
27+
* @internal
2628
* @var string The function name.
2729
*/
2830
public $functionName;
2931

3032
/**
33+
* @internal
3134
* @var ProphecyInterface The prophecy.
3235
*/
3336
public $prophecy;
34-
37+
3538
/**
3639
* Builds the revelation.
3740
*
@@ -45,7 +48,7 @@ public function __construct($namespace, $functionName, ProphecyInterface $prophe
4548
$this->functionName = $functionName;
4649
$this->prophecy = $prophecy;
4750
}
48-
51+
4952
/**
5053
* Reveals the function prophecy.
5154
*

composer.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
}
2020
},
2121
"require": {
22-
"php": ">=5.6",
23-
"php-mock/php-mock-integration": "^1",
24-
"phpspec/prophecy": "^1"
22+
"php": ">=7.2",
23+
"php-mock/php-mock-integration": "^2",
24+
"phpspec/prophecy": "^1.12.1"
2525
},
2626
"require-dev": {
27-
"phpunit/phpunit": "^4|^5"
27+
"phpunit/phpunit": "^8.5.13 || ^9.5",
28+
"squizlabs/php_codesniffer": "^3.5"
2829
},
2930
"archive": {
3031
"exclude": ["/tests"]

phpcs.xml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Coding Standards">
3+
<rule ref="PSR12"/>
4+
5+
<arg name="colors"/>
6+
<arg value="p"/>
7+
8+
<file>classes</file>
9+
<file>tests</file>
10+
</ruleset>

tests/PHPProphetTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
* @license http://www.wtfpl.net/txt/copying/ WTFPL
1414
* @see PHPProphet
1515
*/
16-
class PHPProphetTest extends AbstractMockTest
16+
final class PHPProphetTest extends AbstractMockTest
1717
{
18-
18+
1919
/**
2020
* @var PHPProphet The SUT.
2121
*/
2222
private $prophet;
2323

24-
protected function setup()
24+
protected function setUp(): void
2525
{
2626
parent::setUp();
2727

0 commit comments

Comments
 (0)