Compare commits

...

313 Commits

Author SHA1 Message Date
1bdd3f4908 Update Pest.php 2020-11-09 10:56:14 +01:00
924e095dfc chore: updates changelog 2020-11-09 10:55:22 +01:00
72041a4a21 Merge pull request #215 from olivernybroe/teamcity-exception
Improve exception output in teamcity printer
2020-11-09 10:52:08 +01:00
d576446639 Improve exception output in teamcity printer 2020-11-04 09:17:57 +01:00
3fbec70ed3 chore: updates changelog 2020-11-01 23:22:18 +01:00
d177ab5ec2 feat: support to phpunit v9.4.2 2020-10-20 19:40:38 +02:00
e4f5a284a6 Merge pull request #208 from owenvoke/bugfix/changelog-action
ci(changelog): fix changelog action
2020-10-13 11:16:15 +01:00
6671b266da ci(changelog): fix issue with branch and update to v3 2020-10-13 11:12:34 +01:00
3728bd8e0f ci(changelog): update formatting and run on change 2020-10-13 11:12:06 +01:00
c3616edbc8 docs: update changelog 2020-10-13 10:56:33 +01:00
21143b2693 Merge pull request #207 from fetzi/master
Update phpunit dependency constraint
2020-10-13 10:45:18 +01:00
006f9232cc Update phpunit dependency constraint
allow all versions greater 9.3.7

fixes #205
2020-10-13 11:24:25 +02:00
d1b61a34de Merge pull request #203 from olivernybroe/HelpCommand
Add Pest version to help command
2020-10-08 14:47:19 +02:00
896317ac97 Add Pest version to help command 2020-10-08 11:52:10 +02:00
4fd5c0edd4 Merge pull request #201 from octoper/changelog-action
Update Changelog action
2020-10-06 09:21:42 +02:00
e2c5d6d857 Update Changelog action to point to pestphp/docs 2020-10-06 08:36:41 +02:00
8057fe4bc2 Update Changelog Action 2020-10-06 08:10:57 +02:00
ebc9690301 Merge pull request #134 from sshead/adds-dataset-names
Add name to description for named datasets
2020-10-03 17:39:26 +02:00
049ce1845e chore: update changelog 2020-10-03 12:27:01 +01:00
faa6cd7deb Merge pull request #199 from owenvoke/feature/phpunit-9.4
feat: adds support to PHPUnit 9.4
2020-10-03 12:16:36 +01:00
1f9362c4e7 chore(composer): update to support PHPUnit 9.4 2020-10-02 11:18:10 +01:00
36fd18bcc8 Use Expectation API 2020-10-01 13:59:26 +10:00
aa352317cb Add a named dataset test to output to snapshot 2020-10-01 13:54:17 +10:00
edcd2cb50e Add name to description for named datasets 2020-10-01 13:23:23 +10:00
be8a64e4b8 Merge pull request #196 from DannyvdSluijs/feature-fix-skip-on-higher-order-test
Revert to original target if new target is null
2020-09-30 21:41:59 +02:00
2336bc0f65 Update snapshots 2020-09-30 21:36:05 +02:00
da82eecbae Add tests to ensure working. 2020-09-30 21:32:31 +02:00
4855987ba8 chore: update changelog 2020-09-30 13:03:23 +01:00
a493db1873 Revert to original target if new target is null 2020-09-29 21:51:28 +02:00
4f677a6cc2 Merge pull request #193 from owenvoke/feature/dependencies
chore(composer): add support for PHPUnit 9.3.11
2020-09-24 12:12:03 +01:00
228f2deb64 chore(composer): add support for PHPUnit 9.3.11 2020-09-24 10:45:19 +01:00
0fadf9a02c chore: update changelog 2020-09-21 20:31:32 +01:00
2b138ad76b Merge pull request #191 from owenvoke/feature/assert-regex
feat(expectations): add toMatch
2020-09-21 20:28:42 +01:00
e3e4815b55 chore(expectations): rename 'toMatchRegEx' to 'toMatch' 2020-09-21 20:20:21 +01:00
f76f353c32 chore: update snapshots 2020-09-21 20:19:01 +01:00
16b9f54dc3 feat(expectations): add toMatchRegEx 2020-09-21 20:18:58 +01:00
281166475e Merge pull request #190 from owenvoke/feature/assert-constraint
feat(expectations): add toMatchConstraint
2020-09-21 20:14:39 +01:00
23805cb5d6 chore: update snapshots 2020-09-16 19:03:21 +01:00
76d0f9cfc1 feat(expectations): add toMatchConstraint 2020-09-16 19:02:33 +01:00
5b083e4eb1 chore: update changelog 2020-09-16 10:35:43 +01:00
f48694b18a Merge pull request #187 from owenvoke/feature/assert-string
feat: add 'toStartWith' and 'toEndWith' expectations
2020-09-16 10:33:00 +01:00
8fa59ddbf0 Merge pull request #189 from owenvoke/feature/changelog-workflow
chore: don't run changelog workflow on forks
2020-09-16 09:26:17 +01:00
2619db4026 chore: don't run changelog workflow on forks 2020-09-16 08:26:49 +01:00
f3a71fb100 chore: update snapshots 2020-09-16 08:22:35 +01:00
04fafe742c feat(expectations): add toEndWith 2020-09-16 08:21:46 +01:00
cad8a41e6d feat(expectations): add toStartWith 2020-09-16 08:20:00 +01:00
1567923cda docs: updates changelog 2020-09-15 21:57:50 +02:00
c7116afcae tests: updates snapshots 2020-09-15 21:56:39 +02:00
4e184b2f90 Adds toMatchObject 2020-09-15 21:53:25 +02:00
9b5f664f00 Merge pull request #185 from owenvoke/feature/stubs
chore: update PHPUnit config stubs
2020-09-15 13:06:33 +02:00
0e89525ea8 chore: fix PHPUnit config 2020-09-15 10:45:17 +01:00
0b6cdf8f02 chore: fix PHPUnit config stubs 2020-09-15 10:44:59 +01:00
5f63d959e1 docs: updates changelog 2020-09-13 15:35:49 +02:00
be7fe41179 docs: updates changelog 2020-09-13 15:16:38 +02:00
204f343831 feat: adds toHaveKeys expectation 2020-09-13 15:15:37 +02:00
aa230a1716 docs: updates changelog 2020-09-12 23:46:45 +02:00
97f98569bc feat: adds support to PHPUnit 9.3.9 || 9.3.10 2020-09-12 23:45:22 +02:00
1318bf9830 Merge pull request #141 from olivernybroe/feat-teamcity
feat(teamcity): Add basic teamcity output format
2020-09-11 09:14:33 +01:00
3b58f946f1 Adds Scout APM as premium sponsor 2020-09-11 00:19:43 +02:00
dfc2470764 Merge pull request #179 from owenvoke/feature/badge
docs: fix GitHub Actions badge in README
2020-09-07 12:15:42 +02:00
f650978dd0 docs: fix GitHub Actions badge in README 2020-09-07 11:12:20 +01:00
c6ba469e68 release: version 2020-08-29 23:55:28 +02:00
3a9997f9af docs: updates changelog 2020-08-29 23:55:05 +02:00
fb6cb891be Merge pull request #174 from pestphp/phpunit-upgrade
Allow phpunit 9.3.8 too
2020-08-29 22:59:51 +02:00
76beda74c9 Allow phpunit 9.3.8 too 2020-08-28 16:40:17 +01:00
0398d4223b docs: updates changelog 2020-08-27 22:47:10 +02:00
360eeb4c7d Merge pull request #173 from owenvoke/feature/collision-stable
chore: update to use stable Collision 5
2020-08-26 11:00:43 +01:00
79b4224a35 chore: update to use stable Collision 5 2020-08-26 10:49:46 +01:00
3c79c893c9 Merge pull request #169 from felixdorn/forwards-calls-to-helpers
Forward TestCase bad method calls to global functions
2020-08-25 22:44:57 +02:00
a11f507191 Merge pull request #172 from owenvoke/feature/phpunit-9.3
chore: update PHPUnit configuration for coverage
2020-08-25 22:44:38 +02:00
6413f7040f chore: update PHPUnit configuration for coverage 2020-08-25 21:41:05 +01:00
278af4b835 forward bad TestCase method calls to global functions 2020-08-25 13:45:55 +02:00
fe885fbfb6 Merge pull request #170 from owenvoke/bugfix/snapshot-time
fix: update snapshot generation to strip time
2020-08-25 10:25:23 +02:00
61b2c426e4 fix: update snapshot generation to strip time 2020-08-24 21:29:56 +01:00
4272d49fb7 Merge pull request #165 from owenvoke/bugfix/decoration
fix: don't decorate output if --colors=never is set
2020-08-19 20:28:57 +01:00
014ab3b957 Merge pull request #166 from owenvoke/feature/version
chore: indicate 0.3 dev in version
2020-08-19 20:27:51 +01:00
09a0a64f20 tests: update to use version() in test 2020-08-19 16:56:40 +01:00
bf79f7c63f chore: indicate 0.3 dev in version 2020-08-19 16:48:20 +01:00
36b879f97d fix: don't decorate output if --colors=never is set 2020-08-19 13:46:07 +01:00
bcc206d183 chore(teamcity): static analysis fix 2020-08-18 14:10:32 +02:00
1e7b6a0396 Merge branch 'master' of https://github.com/pestphp/pest into feat-teamcity
 Conflicts:
	phpstan.neon
2020-08-15 08:30:46 +02:00
57a1ccd213 Merge pull request #162 from owenvoke/feature/file-expectations
feat(expectations): add file assertions
2020-08-13 10:15:37 +01:00
708b4b1d49 tests: fix snapshots 2020-08-13 10:03:23 +01:00
3695736b3a tests: update snapshots 2020-08-13 10:03:23 +01:00
8cc9580253 tests(expectations): add tests for file assertions 2020-08-13 10:03:23 +01:00
e1fbf56f3d tests(expectations): fix method in test file 2020-08-13 10:03:23 +01:00
50cd1056eb feat(expectations): add file assertions 2020-08-13 10:03:23 +01:00
cfe6a6728f Merge pull request #163 from owenvoke/feature/rector-php
build: update Rector config to PHP
2020-08-12 15:29:15 +01:00
38344c99f1 style: apply Rector changes 2020-08-12 14:45:55 +01:00
98ed779424 build: update Rector config to PHP 2020-08-12 13:03:15 +01:00
943707cbcd Merge pull request #161 from pestphp/phpunit
Require PHPUnit 9.3.7
2020-08-12 12:13:23 +01:00
940e246f27 Require PHPUnit 7.3.7 2020-08-12 11:39:57 +01:00
439ebcdcaf feat(expectation-api): adds failed assertations on not methods 2020-08-09 19:08:27 +01:00
d2db71bb78 tests: update snapshots 2020-08-09 18:31:08 +01:00
d85432933c Merge pull request #128 from GrahamCampbell/php8
feat: adds support to phpunit 9.3 and php 8.0
2020-08-08 22:53:24 +01:00
3cfadee2bb PHP 8 and PHPUnit 9.3 support 2020-08-07 11:23:45 +01:00
051ca73cae Merge pull request #156 from voyula/patch-2
Add yaml file extension support
2020-08-04 11:19:41 +01:00
50a273f1f1 Add Yaml Support
For: https://github.com/pestphp/pest/blob/master/rector.yaml
2020-08-04 12:54:49 +03:00
ffe5dde7f0 Merge pull request #151 from GrahamCampbell/patch-1
Added additional rector sets
2020-08-04 07:33:54 +01:00
7e1747a364 Merge pull request #150 from innocenzi/fix/command-interactions
Avoid command interactions when the `--no-interaction` flag is given
2020-08-03 21:26:11 +01:00
356b9c01c7 Added additional rector sets 2020-08-03 21:03:17 +01:00
4009177e56 style: fix unary_operator_space 2020-08-03 21:49:09 +02:00
46d1d46384 Merge branch 'master' of https://github.com/pestphp/pest 2020-08-03 20:48:52 +01:00
128ff1006f chore: removes broken rector set 2020-08-03 20:48:45 +01:00
64bb853720 fix: correctly avoid interactions 2020-08-03 21:39:58 +02:00
330dafa294 Merge pull request #145 from AlexMartinFR/patch-2
Update globals.php
2020-08-02 22:53:32 +01:00
a51c354268 Update globals.php
Typo.
2020-08-02 19:25:54 +02:00
cc1abe7f06 fix(teamcity): Fixed a bug when running phpunit tests together with pest tests 2020-07-31 10:25:23 +02:00
0c16942d37 refactor(teamcity): Small cleanup 2020-07-28 11:14:10 +02:00
fa413aafbb style(teamcity): fix styling 2020-07-28 10:51:57 +02:00
75f17bb118 feat(teamcity): Add basic team city output format 2020-07-28 09:11:30 +02:00
19ce733207 Merge pull request #139 from AlexMartinFR/expectations
Polishing Expectation API
2020-07-27 08:47:33 +02:00
7529d44f81 Polishing Expectation API 2020-07-26 17:20:58 +02:00
e4e4eb0a57 chore: bumps deps 2020-07-24 21:54:00 +02:00
c8eb1397b4 Merge pull request #123 from pestphp/feat/expect
feat: add `expect` function
2020-07-18 19:04:37 +02:00
c4c768dcaa tests: update snapshots 2020-07-18 18:57:14 +02:00
8c60a9fff5 Merge pull request #129 from ceceppa/feat/expect
Feat/expect
2020-07-18 18:29:32 +02:00
206e613711 Merge pull request #130 from GrahamCampbell/patch-1
Cleanup actions static analysis
2020-07-16 19:40:49 +02:00
5fb81e9eb4 Update static.yml 2020-07-16 18:36:58 +01:00
d130a1aea0 Cleanup actions static analysis 2020-07-16 18:22:17 +01:00
03201cb8b7 feat(expect): add more methods 2020-07-16 07:57:05 +01:00
46e900e8d2 feat(expect): add more methods 2020-07-16 07:35:31 +01:00
f0f79ab244 feat(expect): add more methods 2020-07-16 07:34:43 +01:00
1e61144cd2 feat(expect): handle property calls to opposite expectations 2020-07-15 01:05:36 +02:00
2751bc9674 feat(expect): fixes to contain with strings 2020-07-15 00:57:31 +02:00
e2deaae6c9 feat(expect): makes expect work with pending higher order tests 2020-07-15 00:34:59 +02:00
1aec8bac55 feat(expect): adds toHaveProperty 2020-07-14 23:37:02 +02:00
32ef377284 feat(expect): removes ignore cases related assertions 2020-07-14 23:21:51 +02:00
ab017e17e2 feat(expect): removes assertions api 2020-07-14 23:15:29 +02:00
832882160f feat(expect): updates test suite to use expectation api 2020-07-14 23:15:14 +02:00
e03d015120 Merge pull request #125 from ceceppa/feat/expect
Feat/expect
2020-07-14 21:13:42 +02:00
819825bdd2 feat(expect): add more methods 2020-07-14 08:08:13 +01:00
d29c789788 feat(expect): add more methods 2020-07-13 17:57:18 +01:00
b4c45af785 feat(expect): add more methods 2020-07-13 17:49:19 +01:00
b4bf799d75 feat(expect): add more methods 2020-07-13 17:38:09 +01:00
9f62f2d483 feat(expect): add more methods 2020-07-13 17:27:55 +01:00
679082e805 feat(expect): add more methods 2020-07-10 07:53:45 +01:00
42f0bd052e feat(expect): add more methods 2020-07-10 07:47:34 +01:00
01b9bab55f feat(expect): adds toBe 2020-07-06 00:32:12 +02:00
3eb0a95955 Merge pull request #121 from owenvoke/feature/changelog-hr
Add 'hr' tag to separate link
2020-07-02 11:20:32 +02:00
d11157f7b2 Add 'hr' tag to separate link 2020-07-02 10:15:48 +01:00
1f2ec74d6c docs: updates changelog 2020-07-02 10:04:29 +01:00
1241e929b1 docs: updates changelog 2020-07-01 20:26:18 +02:00
db7c4b174f refactor: thanks 2020-07-01 20:23:00 +02:00
460ce45349 Merge pull request #118 from owenvoke/feature/thanks
Add --thanks option plugin
2020-07-01 18:51:54 +02:00
8e203e914e Add test for --thanks 2020-07-01 10:27:12 +01:00
64a8ed04ff Add --thanks option plugin 2020-07-01 10:25:22 +01:00
234b6847ad Merge pull request #115 from owenvoke/feature/changelog
Add next section link to the CHANGELOG
2020-06-29 23:12:30 +02:00
933820c8d3 Add next section link to the CHANGELOG
See: https://github.com/pestphp/website/pull/66#discussion_r447211656
2020-06-29 21:45:59 +01:00
4e9587da59 Merge pull request #114 from rkozlov95/normalize-changelogs
docs: updates changelog
2020-06-29 01:25:01 +02:00
60a5db14ba docs: updates changelog 2020-06-29 02:23:49 +03:00
7ea3e02afa Merge pull request #112 from rkozlov95/add-pull-request-template
add pull request template
2020-06-28 01:48:18 +02:00
421c52fb74 add pull request template 2020-06-28 02:18:24 +03:00
a3644f7efa tests: fixes windows tests 2020-06-26 18:42:57 +02:00
c7326f430b chore: fixes required version of collision 2020-06-26 18:28:47 +02:00
9ea51caf3f feat: adds --version option 2020-06-26 18:17:11 +02:00
cb4c9563bd Merge pull request #109 from Gummibeer/patch-1
pass calls to overloaded method if possible
2020-06-21 18:53:12 +02:00
fac44d9afe revert to first approach by calling __call directly 2020-06-21 18:46:11 +02:00
6e27c6d85d fix tye check 2020-06-21 18:44:04 +02:00
9a0cfaf339 use shorter beforeEach chain syntax 2020-06-21 18:39:47 +02:00
321b3e8df3 use call_user_func_array instead of direct calling __call
add check for __callStatic
2020-06-21 18:31:09 +02:00
bff97418ed do not return $this 2020-06-21 18:27:43 +02:00
a47ad6a1d3 Merge branch 'master' of https://github.com/pestphp/pest into patch-1
# Conflicts:
#	tests/.snapshots/success.txt
2020-06-21 18:25:57 +02:00
74c14808cf rebuild success.txt 2020-06-21 18:24:49 +02:00
eff2d7f613 fix test and add exception test 2020-06-21 18:23:39 +02:00
e135979f34 revert null old-target logic 2020-06-21 18:22:34 +02:00
15edde8e87 docs: updates changelog 2020-06-21 17:43:28 +02:00
211f5c2433 tests: makes incomplete tests success 2020-06-21 17:40:41 +02:00
5d58d58f71 chore: updates phpstan config 2020-06-21 17:40:29 +02:00
d5a4008d3e chore: bumps dev dependencies 2020-06-21 17:40:17 +02:00
1bf802268f Merge pull request #103 from nuernbergerA/feature/depends
Add support for PHPUnit's @depends
2020-06-21 17:10:58 +02:00
807a4b004f Merge branch 'master' into feature/depends 2020-06-21 17:10:51 +02:00
53a8c7b05e add test for new macro behavior 2020-06-21 14:02:56 +02:00
ef5715ce10 ignore null return values and re-use old target 2020-06-21 14:02:42 +02:00
0c04882389 use long exception variable name 2020-06-21 13:08:06 +02:00
323c5f211f pass calls to overloaded method if possible
fix #108
2020-06-21 11:55:32 +02:00
f7a3fa15f4 Merge pull request #101 from fetzi/bugfix/dataset-name-creation
Fix dataset name creation with objects
2020-06-20 21:42:16 +02:00
6dd3ca20e4 Also handle multiple descriptions within whole dataset 2020-06-20 11:29:07 +02:00
d9ea378819 Only append numbers when data set desc is the same 2020-06-20 09:53:38 +02:00
6aa0356570 add more tests 2020-06-19 23:22:14 +02:00
45b0d5d899 feat(depends): adds phpdocs 2020-06-19 21:39:01 +02:00
5be1edd7b7 added missing return types 2020-06-19 21:25:38 +02:00
75f7ee0acf added feedback from @nunomaduro 2020-06-19 20:39:09 +02:00
d0a74931dd implemented support for PHPUnit's @depends 2020-06-19 19:50:54 +02:00
0738e113ad Fix dataset name creation with objects
fixes #98
2020-06-19 16:03:47 +02:00
283d8f3e03 docs: updates changelog 2020-06-17 18:57:54 +02:00
1c3e820283 Merge pull request #97 from fkraefft/fix-traits
Fix in Test Repository use method.
2020-06-17 18:47:00 +02:00
accd4eb7b4 Multiple global uses registered in the same path test added. 2020-06-17 11:57:08 -03:00
ae7991c7e9 Style fixes. 2020-06-17 11:56:24 -03:00
e9e72d607e vscode folder added to gitignore. 2020-06-17 11:55:48 -03:00
40766f9275 Fix in Test Repository use method. 2020-06-17 09:59:46 -03:00
a3fd60ce4d docs: updates changelog 2020-06-14 17:01:15 +02:00
f9a3e39902 tests: removes test coverage for now
Co-Authored-By: Johannes Pichler <fetzi@users.noreply.github.com>
2020-06-14 16:35:30 +02:00
06d707fb41 feat(container): makes it autowirable
Co-Authored-By: Johannes Pichler <fetzi@users.noreply.github.com>
2020-06-14 16:25:51 +02:00
a70c64d704 tests: removes unused file 2020-06-14 16:23:54 +02:00
3a78aaef8f fix(container): resolves dependencies without contructor
Co-Authored-By: Johannes Pichler <fetzi@users.noreply.github.com>
2020-06-14 16:15:05 +02:00
c79c0feec8 feat(namespaced-functions): updates stubs 2020-06-14 02:16:14 +02:00
39a5a94f3e feat(namespaced-helpers): udpates stubs 2020-06-14 01:03:35 +02:00
961bfcaff7 Merge pull request #80 from owenvoke/feature/problem-matchers
Add problem matcher output to CI
2020-06-12 14:47:45 +02:00
52ba5dbd00 Add problem matcher output to CI 2020-06-12 13:37:17 +01:00
518b056fb9 fix: do not force having tests folder 2020-06-12 02:12:51 +02:00
f9a936b4d9 tests: namespace helpers 2020-06-11 21:56:15 +02:00
4448761852 Merge pull request #78 from felixdorn/patch-1
Optimise debug_backtrace calls
2020-06-11 21:46:23 +02:00
1192d13e6b add memory optimisation for Backtrace::testFile() 2020-06-11 16:38:31 +02:00
57b982de48 fix ci build 2020-06-11 16:31:14 +02:00
a3366379e0 optimise debug_backtrace calls 2020-06-11 16:13:17 +02:00
cd8d8fce61 chore: skips visual tests on windows for now 2020-06-10 21:38:45 +02:00
4254d71039 tests: fixes visual testing on windows 2020-06-10 21:32:54 +02:00
bd48232c61 chore: runs tests on windows 2020-06-10 21:17:56 +02:00
70b3c7ea1d chore: adds init plugin 2020-06-07 20:16:26 +02:00
c186035a13 chore: fixes duplicated branch alias 2020-06-05 22:44:48 +02:00
2efed3ef80 Merge pull request #65 from fetzi/feature/add-container
Add basic container implementation
2020-06-05 22:39:57 +02:00
58f2581307 Merge branch 'master' into feature/add-container 2020-06-05 22:39:02 +02:00
6c4fd61db5 tests: fixes testing running in php 7.3 2020-06-05 20:51:57 +02:00
afbbc35984 tests: refactor visual testing 2020-06-05 20:49:14 +02:00
a13c19cc29 chore: fixes deps 2020-06-05 20:04:10 +02:00
7d7c5f1ab1 Merge pull request #61 from dimitrioskarvounaris/windows-gitbash
Fixes autoloading, plugins and tests on Windows
2020-06-05 20:01:55 +02:00
865f33bf80 // fixing type check 2020-06-05 19:45:58 +02:00
e33419545c // fixing once more, wrong code pasted :( 2020-06-05 19:42:07 +02:00
b93cd724c1 // tiny fix 2020-06-05 19:37:53 +02:00
40a5d067ec // fixing type checks 2020-06-05 19:35:13 +02:00
3640ab0945 // unnecessary linebreak 2020-06-05 19:30:35 +02:00
cb2336d220 // missing change 2020-06-05 19:29:43 +02:00
71fcb281b0 Merge branch 'windows-gitbash' of github.com:dimitrioskarvounaris/pest into windows-gitbash 2020-06-05 19:25:23 +02:00
d24830121e Reverting changes from c05df432 2020-06-05 19:24:56 +02:00
5a00a732e3 Merge branch 'master' into windows-gitbash 2020-06-05 18:37:24 +02:00
38584bec93 Updating success.txt snapshot 2020-06-05 18:31:40 +02:00
ffa3f1d683 Skip visual snapshot test on Windows 2020-06-05 18:26:52 +02:00
dff9bbc134 Fix file paths not being used properly
basename() will strip full path information on some systems.
What is needed is to use both dirname() & basename() on paths,
as recognized by all systems, and only afterwards do any
replacements.
2020-06-05 18:24:03 +02:00
f5f717f1ad chore: requires more than collision beta1 2020-06-05 18:18:06 +02:00
9bdd254007 tests: adapts to collision beta 2 2020-06-05 18:14:27 +02:00
6e18912ea6 Test to check if the full test path is shown 2020-06-05 17:38:59 +02:00
d35320c697 Compare filename correctly on all OS 2020-06-05 17:25:53 +02:00
fe11140fc2 Adding dom extension to CI 2020-06-05 16:23:12 +02:00
0d198f589d Fix changes in success snapshot 2020-06-05 16:23:12 +02:00
8a42d40506 traits from Autoload.php not loading on Windows
Windows requires realpath() so the case of the
paths and filenames are always identical
2020-06-05 16:23:11 +02:00
83797431fb in() does not handle absolute paths under Windows
This fixes plugins to be included incorrectly under Windows
2020-06-05 16:23:11 +02:00
c05df43217 Compare lines without involving linebreaks
Fixes tests failing under Windows environments
for any linebreak character differences
2020-06-05 16:23:11 +02:00
f6859eeb3b Launch pest as php subprocess 2020-06-05 16:23:11 +02:00
a0b8082631 Fix issue with case-insensitive windows paths 2020-06-05 16:23:11 +02:00
926d8ecb8d Call binary as php sub process 2020-06-05 16:23:11 +02:00
24f85354e2 Normalize Windows dir name in TestCaseFactory 2020-06-05 16:21:35 +02:00
163de28338 Make sure PHP is called before calling pest as sub process 2020-06-05 16:21:35 +02:00
3d2c83a501 Make sure test targets are sanitized in a windows-compatible way 2020-06-05 16:21:35 +02:00
b0c964d4d9 Don't use "reapath" in binary for cross-compatibility 2020-06-05 16:21:35 +02:00
20d2d9f3b7 Merge pull request #69 from octoper/master
Update Changelog action
2020-06-05 16:15:30 +02:00
6b7aa10e91 Update changelog.yml 2020-06-05 17:03:32 +03:00
067aa58817 Merge branch 'feature/add-container' of github.com:fetzi/pest into feature/add-container 2020-06-05 11:53:17 +02:00
337e751200 Update plugin interfaces and instantiate container 2020-06-05 11:52:23 +02:00
b20f208b55 Add basic container implementation 2020-06-05 11:51:33 +02:00
9899b3c3a4 Update plugin interfaces and instantiate container 2020-06-05 07:48:51 +02:00
6437db7aa0 Updated changelog action 2020-06-05 06:18:18 +03:00
7d38d4bd4f Updated changelog action 2020-06-05 06:16:03 +03:00
e8d426f574 Removes windows for now 2020-06-04 23:09:40 +02:00
bb711108a2 Merge pull request #68 from octoper/patch-1
Update CHANGELOG.md
2020-06-04 22:14:16 +02:00
a482341b99 Update CHANGELOG.md 2020-06-04 21:22:29 +03:00
f5ce472006 Merge pull request #66 from pestphp/feat/pending-higher-order-tests
feat: adds pending higher order tests
2020-06-04 19:40:18 +02:00
a53ff3e459 Merge pull request #67 from octoper/master
fixed changelog action
2020-06-04 16:31:38 +02:00
e15d77f3f6 Update changelog.yml 2020-06-04 17:03:47 +03:00
504128730c Update changelog.yml 2020-06-04 16:53:08 +03:00
098acaecc0 Merge pull request #1 from pestphp/master
Pulling changes from pestphp/pest
2020-06-04 16:50:19 +03:00
b2dd573a67 Merge pull request #64 from octoper/master
Created Update CHANGELOG action
2020-06-04 15:17:29 +02:00
84c9078bb7 Add basic container implementation 2020-06-04 11:58:28 +02:00
aa1917c28d feat(pending-higher-order-tests): adds code and tests 2020-06-04 01:34:03 +02:00
c81dce0f6d feat(pending-higher-order-tests): adds code and tests 2020-06-04 01:33:33 +02:00
249869c2db Updated update_changelog to changelog action 2020-06-03 17:37:48 +03:00
d59d8d6245 Created update_changelog action 2020-06-03 17:32:07 +03:00
b0680b7e2c chore: cs 2020-05-31 13:42:27 +02:00
c7fd21999b Merge pull request #51 from Jibbarth/feature/support-colors-never
Feature/support colors never
2020-05-31 13:39:55 +02:00
28d06663d3 Add tests for --colors=never option 2020-05-31 12:33:27 +02:00
73f56e58a5 Pass color and verbosity args to printer (fix #49) 2020-05-31 12:32:43 +02:00
76796ffc67 refacto: includes coverage plugin 2020-05-30 01:43:02 +02:00
01daf0316c refacto: removes unused code about coverage 2020-05-29 22:44:41 +02:00
1f2976c0e0 tests: types 2020-05-29 22:35:20 +02:00
2e7ed741b6 fix: keeps result from plugin to plugin 2020-05-29 22:33:05 +02:00
a0a4730ef8 Merge branch 'master' of https://github.com/pestphp/pest 2020-05-29 22:28:47 +02:00
5ed927d226 Merge pull request #43 from fetzi/plugins
Integrate pest-plugins with 2 interfaces
2020-05-29 22:08:39 +02:00
78cdd4da36 Update composer.json 2020-05-29 21:15:51 +02:00
332139e614 Merge pull request #37 from owenvoke/bugfix/windows
Fix Windows builds running Pest
2020-05-29 20:12:54 +02:00
b093e8ee29 Integrate pest-plugins with 2 interfaces
integrate pest-plugin package and remove core coverage stuff
2020-05-29 11:28:06 +02:00
937374431a Fix Windows builds running Pest 2020-05-28 08:46:05 +01:00
ddc08cf0f9 docs: updates changelog 2020-05-24 21:41:35 +02:00
88d2391d2e fix: colors on coverage 2020-05-24 21:40:10 +02:00
bd02196950 docs: updates changelog 2020-05-24 21:32:53 +02:00
4de6019206 Merge pull request #18 from michaeldyrynda/master
Add support for installing Pest into a Lumen application
2020-05-24 20:43:23 +02:00
85630b0aa2 Merge pull request #22 from pgrimaud/master
Fix typos
2020-05-24 20:03:20 +02:00
0fda39467c Merge pull request #24 from AlexMartinFR/patch-1
Update README.md
2020-05-24 20:02:36 +02:00
415f571910 fix: mockery tests being considered as risky 2020-05-24 20:00:30 +02:00
8284219035 Update README.md
Typo.
2020-05-24 19:35:35 +02:00
d0d34c7872 Fix typos 2020-05-24 12:37:33 +02:00
2869f11ae5 use ->in(__DIR__) in base Pest.php file 2020-05-24 13:36:17 +09:30
340c7ca04e Merge pull request #20 from aniplaylist/patch-1
Fix typo in beforeAll() PHPDoc block
2020-05-24 00:48:21 +02:00
81a646d64e Fix typo in beforeAll() PHPDoc block 2020-05-23 23:01:03 +02:00
c23f2e4bd6 fix errors from type checks 2020-05-23 21:09:28 +09:30
4496e9d9ee Add support for installing Pest into a Lumen application
This entails creating Laravel and Lumen-specific stubs, and ensuring
that the appropriate stubs are copied as part of the pest install.
2020-05-23 20:52:15 +09:30
ce14ffd49a chore: fixes duplicated name on workflow 2020-05-21 23:25:43 +02:00
c18c481628 chore: updates names in github actions workflow 2020-05-21 23:13:32 +02:00
0695ea5d33 chore: runs formats testing in ubuntu only 2020-05-21 23:00:16 +02:00
2e321f5465 chore: fixes build 2020-05-21 22:49:46 +02:00
cbeec31bfc chore: adds windows build 2020-05-21 22:46:46 +02:00
69f6a22121 docs: updates changelog 2020-05-21 22:22:34 +02:00
9a179d2891 chore: coding style 2020-05-21 21:48:47 +02:00
6c4be0190e feat: adds plugin uses api 2020-05-21 21:44:05 +02:00
5c6bb43d8d docs: updates readme badges 2020-05-20 01:30:05 +02:00
e536c28e34 docs: updates readme 2020-05-16 22:58:45 +02:00
67bb23cda3 Update README.md 2020-05-16 22:57:48 +02:00
59398cfcf8 docs: updates license 2020-05-16 22:37:50 +02:00
182377abe3 docs: adds twitter link 2020-05-16 22:34:00 +02:00
242e74964b docs: updates readme banner 2020-05-16 22:24:20 +02:00
9a2c7e45f7 docs: updates discord link 2020-05-15 18:19:56 +02:00
99205c4aa8 docs: updates changelog 2020-05-15 02:15:32 +02:00
1268384fb3 Merge pull request #7 from pestphp/feat/helpers
feat(helpers): adds helpers file
2020-05-15 02:12:12 +02:00
c97fd17120 feat(helpers): adds helpers file 2020-05-14 23:03:56 +02:00
144 changed files with 3452 additions and 2558 deletions

View File

@ -14,5 +14,5 @@ trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.yml]
[*.{yml,yaml}]
indent_size = 2

10
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,10 @@
| Q | A
| ------------- | ---
| Bug fix? | yes/no
| New feature? | yes/no
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
<!--
- Replace this comment by a description of what your PR is solving.
-->

63
.github/workflows/changelog.yml vendored Normal file
View File

@ -0,0 +1,63 @@
name: Changelog
on:
push:
branches: [ master ]
paths:
- CHANGELOG.md
- .github/workflows/changelog.yml
pull_request:
branches: [ master ]
paths:
- CHANGELOG.md
jobs:
build:
runs-on: ubuntu-latest
if: github.repository == 'pestphp/pest'
steps:
- uses: actions/checkout@v2
- name: Checkout website repository
uses: actions/checkout@v2
with:
token: ${{ secrets.CHANGELOG_KEY }}
repository: pestphp/docs
path: pestphp-docs
ref: master
- name: Read CHANGELOG.md
id: package
uses: juliangruber/read-file-action@v1
with:
path: ./CHANGELOG.md
- name: Add file headers
uses: DamianReeves/write-file-action@v1.0
with:
path: ./CHANGELOG.md
contents: |
---
title: Changelog
description: Changelog
---
${{ steps.package.outputs.content }}
----
Next section: [Upgrade Guide →](/docs/upgrade-guide)
write-mode: overwrite
- name: Copy CHANGELOG to website repository
run: cp CHANGELOG.md pestphp-docs/changelog.md
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.CHANGELOG_KEY }}
commit-message: Update changelog.md
committer: GitHub Action <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
title: 'Update changelog.md'
path: ./pestphp-docs

View File

@ -1,51 +0,0 @@
name: Continuous Integration
on: ['push', 'pull_request']
jobs:
ci:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [7.3, 7.4]
dependency-version: [prefer-lowest, prefer-stable]
name: CI - PHP ${{ matrix.php }} (${{ matrix.dependency-version }})
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, zip
tools: prestissimo
coverage: pcov
- name: Install Composer dependencies
run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist
- name: Coding Style Checks
run: |
vendor/bin/rector process src --dry-run
vendor/bin/php-cs-fixer fix -v --dry-run
- name: Type Checks
run: vendor/bin/phpstan analyse --ansi
- name: Unit Tests
run: bin/pest --colors=always --exclude-group=integration
- name: Integration Tests
run: bin/pest --colors=always --group=integration

54
.github/workflows/static.yml vendored Normal file
View File

@ -0,0 +1,54 @@
name: Static Analysis
on: ['push', 'pull_request']
jobs:
cs:
runs-on: ubuntu-latest
name: Code Style
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
tools: composer:v2
coverage: none
- name: Install Dependencies
run: composer update --no-interaction --no-progress
- name: Run Rector
run: vendor/bin/rector process src --dry-run
- name: Run PHP-CS-Fixer
run: vendor/bin/php-cs-fixer fix -v --allow-risky=yes --dry-run
phpstan:
runs-on: ubuntu-latest
strategy:
matrix:
dependency-version: [prefer-lowest, prefer-stable]
name: PHPStan ${{ matrix.dependency-version }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
tools: composer:v2
coverage: none
- name: Install Dependencies
run: composer update --prefer-stable --no-interaction --no-progress
- name: Run PHPStan
run: vendor/bin/phpstan analyse --no-progress

44
.github/workflows/tests.yml vendored Normal file
View File

@ -0,0 +1,44 @@
name: Tests
on: ['push', 'pull_request']
jobs:
ci:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
php: ['7.3', '7.4', '8.0']
dependency-version: [prefer-lowest, prefer-stable]
name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none
- name: Setup Problem Matches
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install PHP 7 dependencies
run: composer update --${{ matrix.dependency-version }} --no-interaction --no-progress
if: "matrix.php < 8"
- name: Install PHP 8 dependencies
run: composer update --${{ matrix.dependency-version }} --ignore-platform-req=php --no-interaction --no-progress
if: "matrix.php >= 8"
- name: Unit Tests
run: php bin/pest --colors=always --exclude-group=integration
- name: Integration Tests
run: php bin/pest --colors=always --group=integration

1
.gitignore vendored
View File

@ -8,3 +8,4 @@ coverage.xml
.temp/coverage.php
*.swp
*.swo
.vscode/

View File

@ -3,7 +3,6 @@
$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . DIRECTORY_SEPARATOR . 'tests')
->in(__DIR__ . DIRECTORY_SEPARATOR . 'bin')
->in(__DIR__ . DIRECTORY_SEPARATOR . 'compiled')
->in(__DIR__ . DIRECTORY_SEPARATOR . 'scripts')
->in(__DIR__ . DIRECTORY_SEPARATOR . 'stubs')
->in(__DIR__ . DIRECTORY_SEPARATOR . 'src')

View File

@ -4,7 +4,120 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
## [v0.3.11 (2020-11-09)](https://github.com/pestphp/pest/compare/v0.3.10...v0.3.11)
### Changed
- Improved the exception output for the TeamCity printer (usage with phpstorm plugin) ([#215](https://github.com/pestphp/pest/pull/215))
## [v0.3.10 (2020-11-01)](https://github.com/pestphp/pest/compare/v0.3.9...v0.3.10)
### Added
- Add support for PHPUnit 9.4.2 ([d177ab5](https://github.com/pestphp/pest/commit/d177ab5ec2030c5bb8e418d10834c370c94c433d))
## [v0.3.9 (2020-10-13)](https://github.com/pestphp/pest/compare/v0.3.8...v0.3.9)
### Added
- Add support for named datasets in description output ([#134](https://github.com/pestphp/pest/pull/134))
- Add Pest version to `--help` output ([#203](https://github.com/pestphp/pest/pull/203))
- Add support for PHPUnit 9.4.1 ([#207](https://github.com/pestphp/pest/pull/207))
## [v0.3.8 (2020-10-03)](https://github.com/pestphp/pest/compare/v0.3.7...v0.3.8)
### Added
- Add support for PHPUnit 9.4.0 ([#199](https://github.com/pestphp/pest/pull/199))
### Fixed
- Fix chained higher order assertions returning void ([#196](https://github.com/pestphp/pest/pull/196))
## [v0.3.7 (2020-09-30)](https://github.com/pestphp/pest/compare/v0.3.6...v0.3.7)
### Added
- Add support for PHPUnit 9.3.11 ([#193](https://github.com/pestphp/pest/pull/193))
## [v0.3.6 (2020-09-21)](https://github.com/pestphp/pest/compare/v0.3.5...v0.3.6)
### Added
- `toMatch` expectation ([#191](https://github.com/pestphp/pest/pull/191))
- `toMatchConstraint` expectation ([#190](https://github.com/pestphp/pest/pull/190))
## [v0.3.5 (2020-09-16)](https://github.com/pestphp/pest/compare/v0.3.4...v0.3.5)
### Added
- `toStartWith` and `toEndWith` expectations ([#187](https://github.com/pestphp/pest/pull/187))
## [v0.3.4 (2020-09-15)](https://github.com/pestphp/pest/compare/v0.3.3...v0.3.4)
### Added
- `toMatchObject` expectation ([4e184b2](https://github.com/pestphp/pest/commit/4e184b2f906c318a5e9cd38fe693cdab5c48d8a2))
## [v0.3.3 (2020-09-13)](https://github.com/pestphp/pest/compare/v0.3.2...v0.3.3)
### Added
- `toHaveKeys` expectation ([204f343](https://github.com/pestphp/pest/commit/204f343831adc17bb3734553c24fac92d02f27c7))
## [v0.3.2 (2020-09-12)](https://github.com/pestphp/pest/compare/v0.3.1...v0.3.2)
### Added
- Support to PHPUnit 9.3.9, and 9.3.10 ([1318bf9](https://github.com/pestphp/pest/commit/97f98569bc86e8b87f8cde963fe7b4bf5399623b))
## [v0.3.1 (2020-08-29)](https://github.com/pestphp/pest/compare/v0.3.0...v0.3.1)
### Added
- Support to PHPUnit 9.3.8 ([#174](https://github.com/pestphp/pest/pull/174))
## [v0.3.0 (2020-08-27)](https://github.com/pestphp/pest/compare/v0.2.3...v0.3.0)
### Added
- Expectation API (TODO)
- PHPUnit 9.3 and PHP 8 support ([#128](https://github.com/pestphp/pest/pull/128))
- Fowards `$this` calls to globals ([#169](https://github.com/pestphp/pest/pull/169))
### Fixed
- don't decorate output if --colors=never is set ([36b879f](https://github.com/pestphp/pest/commit/36b879f97d7b187c87a94eb60af5b7d3b7253d56))
## [v0.2.3 (2020-07-01)](https://github.com/pestphp/pest/compare/v0.2.2...v0.2.3)
### Added
- `--init` and `pest:install` artisan command output changes ([#118](https://github.com/pestphp/pest/pull/118), [db7c4b1](https://github.com/pestphp/pest/commit/db7c4b174f0974969450dda71dcd649ef0c073a3))
- `--version` option to view the current version of Pest ([9ea51ca](https://github.com/pestphp/pest/commit/9ea51caf3f74569debb1e465992e9ea916cb80fe))
## [v0.2.2 (2020-06-21)](https://github.com/pestphp/pest/compare/v0.2.1...v0.2.2)
### Added
- `depends` phpunit feature ([#103](https://github.com/pestphp/pest/pull/103))
### Fixes
- datasets name conflit ([#101](https://github.com/pestphp/pest/pull/101))
## [v0.2.1 (2020-06-17)](https://github.com/pestphp/pest/compare/v0.2.0...v0.2.1)
### Fixes
- Multiple `uses` in the same path override previous `uses` ([#97](https://github.com/pestphp/pest/pull/97))
## [v0.2.0 (2020-06-14)](https://github.com/pestphp/pest/compare/v0.1.5...v0.2.0)
### Adds
- `--init` option to install Pest on a new blank project ([70b3c7e](https://github.com/pestphp/pest/commit/70b3c7ea1ddb031f3bbfaabdc28d56270608ebbd))
- pending higher orders tests aka tests without description ([aa1917c](https://github.com/pestphp/pest/commit/aa1917c28d9b69c2bd1d51f986c4f61318ee7e16))
### Fixed
- `--verbose` and `--colors` options not being used by printers ([#51](https://github.com/pestphp/pest/pull/51))
- missing support on windows ([#61](https://github.com/pestphp/pest/pull/61))
### Changed
- `helpers.php` stub provides now namespaced functions
- functions provided by plugins are now namespaced functions:
```php
use function Pest\Faker\faker;
it('foo', function () {
$name = faker()->name;
});
```
## [v0.1.5 (2020-05-24)](https://github.com/pestphp/pest/compare/v0.1.4...v0.1.5)
### Fixed
- Missing default decorated output on coverage ([88d2391](https://github.com/pestphp/pest/commit/88d2391d2e6fe9c9416462734b9b523cb418f469))
## [v0.1.4 (2020-05-24)](https://github.com/pestphp/pest/compare/v0.1.3...v0.1.4)
### Added
- Support to Lumen on artisan commands ([#18](https://github.com/pestphp/pest/pull/18))
### Fixed
- Mockery tests without assertions being considered risky ([415f571](https://github.com/pestphp/pest/commit/415f5719101b30c11d87f74810a71686ef2786c6))
## [v0.1.3 (2020-05-21)](https://github.com/pestphp/pest/compare/v0.1.2...v0.1.3)
### Added
- `Plugin::uses()` method for making traits globally available ([6c4be01](https://github.com/pestphp/pest/commit/6c4be0190e9493702a976b996bbbf5150cc6bb53))
## [v0.1.2 (2020-05-15)](https://github.com/pestphp/pest/compare/v0.1.1...v0.1.2)
### Added
- Support to custom helpers ([#7](https://github.com/pestphp/pest/pull/7))
## [v0.1.1 (2020-05-14)](https://github.com/pestphp/pest/compare/v0.1.0...v0.1.1)
### Added

View File

@ -1,17 +1,26 @@
<p align="center">
<img src="https://next.pestphp.com/assets/img/og.png" width="600" alt="PEST Preview">
<img src="https://raw.githubusercontent.com/pestphp/art/master/readme.png" width="600" alt="PEST">
<p align="center">
<a href="https://github.com/pestphp/pest/actions"><img src="https://github.com/pest/pestphp/workflows/tests/badge.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/pestphp/pest"><img src="https://poser.pugx.org/pestphp/pest/d/total.svg" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/pestphp/pest"><img src="https://poser.pugx.org/pestphp/pest/v/stable.svg" alt="Latest Version"></a>
<a href="https://packagist.org/packages/pestphp/pest"><img src="https://poser.pugx.org/pestphp/pest/license.svg" alt="License"></a>
<a href="https://github.com/pestphp/pest/actions"><img alt="GitHub Workflow Status (master)" src="https://img.shields.io/github/workflow/status/pestphp/pest/Tests/master"></a>
<a href="https://packagist.org/packages/pestphp/pest"><img alt="Total Downloads" src="https://img.shields.io/packagist/dt/pestphp/pest"></a>
<a href="https://packagist.org/packages/pestphp/pest"><img alt="Latest Version" src="https://img.shields.io/packagist/v/pestphp/pest"></a>
<a href="https://packagist.org/packages/pestphp/pest"><img alt="License" src="https://img.shields.io/packagist/l/pestphp/pest"></a>
</p>
</p>
------
**Pest** it's an elegant PHP Testing Framework with a focus on simplicity. It was carefully crafted to bring the joy of testing to PHP.
**Pest** is an elegant PHP Testing Framework with a focus on simplicity. It was carefully crafted to bring the joy of testing to PHP.
- Explore the docs: **[pestphp.com »](https://pestphp.com)**
- Join the Discord Server: **[discord.gg/4UMHUb5 »](https://discord.gg/4UMHUb5)**
- Follow us on Twitter: **[@pestphp »](https://twitter.com/pestphp)**
- Join us on the Discord Server: **[discord.gg/bMAJv82 »](https://discord.gg/bMAJv82)**
Pest was created by **[Nuno Maduro](https://twitter.com/enunomaduro)** and is open-sourced software licensed under the **[MIT license](https://opensource.org/licenses/MIT)**.
## Pest Sponsors
We would like to extend our thanks to the following sponsors for funding Pest development. If you are interested in becoming a sponsor, please visit the Nuno Maduro's [Sponsors page](https://github.com/sponsors/nunomaduro).
### Premium Sponsors
- **[Scout APM](https://github.com/scoutapp)**
Pest was created by **[Nuno Maduro](https://twitter.com/enunomaduro)** under the **[Sponsorware license](https://github.com/sponsorware/docs)**. It got open-sourced and is now licensed under the **[MIT license](https://opensource.org/licenses/MIT)**.

View File

@ -1,31 +1,42 @@
#!/usr/bin/env php
<?php declare(strict_types=1);
use NunoMaduro\Collision\Provider;
use Pest\Actions\ValidatesEnvironment;
use Pest\Console\Command;
use Pest\Support\Container;
use Pest\TestSuite;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface;
(static function () {
// Used when Pest is required using composer.
$vendorPath = realpath(__DIR__ . '/../../../../vendor/autoload.php');
$vendorPath = dirname(__DIR__, 4) . '/vendor/autoload.php';
// Used when Pest maintainers are running Pest tests.
$localPath = realpath(__DIR__ . '/../vendor/autoload.php');
$localPath = dirname(__DIR__) . '/vendor/autoload.php';
if ($vendorPath) {
if (file_exists($vendorPath)) {
include_once $vendorPath;
} else {
include_once $localPath;
}
(new \NunoMaduro\Collision\Provider)->register();
(new Provider())->register();
$rootPath = getcwd();
$testSuite = TestSuite::getInstance($rootPath);
$isDecorated = (new ArgvInput())->getParameterOption('--colors', 'always') !== 'never';
$output = new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, $isDecorated);
$container = Container::getInstance();
$container->add(TestSuite::class, $testSuite);
$container->add(OutputInterface::class, $output);
ValidatesEnvironment::in($testSuite);
exit((new Command($testSuite, new ConsoleOutput()))->run($_SERVER['argv']));
exit($container->get(Command::class)->run($_SERVER['argv']));
})();

View File

File diff suppressed because it is too large Load Diff

View File

@ -17,10 +17,12 @@
}
],
"require": {
"php": "^7.3",
"php": "^7.3 || ^8.0",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.1.4",
"sebastian/environment": "^5.1"
"pestphp/pest-plugin": "^0.3",
"pestphp/pest-plugin-coverage": "^0.3",
"pestphp/pest-plugin-init": "^0.3",
"phpunit/phpunit": ">= 9.3.7 <= 9.4.2"
},
"autoload": {
"psr-4": {
@ -28,25 +30,22 @@
},
"files": [
"src/globals.php",
"compiled/globals.php"
"src/Pest.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/PHPUnit/"
}
},
"files": [
"tests/Autoload.php"
]
},
"require-dev": {
"ergebnis/phpstan-rules": "^0.14.4",
"friendsofphp/php-cs-fixer": "^2.16.3",
"illuminate/console": "^7.10.3",
"illuminate/support": "^7.10.3",
"mockery/mockery": "^1.3.1",
"phpstan/phpstan": "^0.12.25",
"phpstan/phpstan-strict-rules": "^0.12.2",
"rector/rector": "^0.7.25",
"symfony/var-dumper": "^5.0.8",
"thecodingmachine/phpstan-strict-rules": "^0.12.0"
"illuminate/console": "^7.16.1",
"illuminate/support": "^7.16.1",
"mockery/mockery": "^1.4.1",
"pestphp/pest-dev-tools": "dev-master"
},
"minimum-stability": "dev",
"prefer-stable": true,
@ -58,13 +57,12 @@
"bin/pest"
],
"scripts": {
"compile": "@php ./scripts/compile.php",
"lint": "rector process src && php-cs-fixer fix -v",
"test:lint": "php-cs-fixer fix -v --dry-run && rector process src --dry-run",
"test:types": "phpstan analyse --ansi",
"test:unit": "bin/pest --colors=always --exclude-group=integration",
"test:integration": "bin/pest --colors=always --group=integration",
"test:integration:snapshots": "REBUILD_SNAPSHOTS=true bin/pest --colors=always",
"test:types": "phpstan analyse --ansi --memory-limit=0",
"test:unit": "php bin/pest --colors=always --exclude-group=integration",
"test:integration": "php bin/pest --colors=always --group=integration",
"update:snapshots": "REBUILD_SNAPSHOTS=true php bin/pest --colors=always",
"test": [
"@test:lint",
"@test:types",
@ -73,6 +71,14 @@
]
},
"extra": {
"branch-alias": {
"dev-master": "0.4.x-dev"
},
"pest": {
"plugins": [
"Pest\\Plugins\\Version"
]
},
"laravel": {
"providers": [
"Pest\\Laravel\\PestServiceProvider"

View File

@ -15,8 +15,19 @@ parameters:
reportUnmatchedIgnoredErrors: true
ignoreErrors:
- "#Undefined variable: \\$this#"
- "#is not allowed to extend#"
- "#Language construct eval#"
- "# with null as default value#"
- "#Using \\$this in static method#"
- "#has parameter \\$closure with default value.#"
- "#has parameter \\$description with default value.#"
- "#Method Pest\\\\Support\\\\Reflection::getParameterClassName\\(\\) has a nullable return type declaration.#"
-
message: '#Call to an undefined method PHPUnit\\Framework\\Test::getName\(\)#'
path: src/TeamCity.php
-
message: '#invalid typehint type Pest\\Concerns\\TestCase#'
path: src/TeamCity.php
-
message: '#is not subtype of native type PHPUnit\\Framework\\Test#'
path: src/TeamCity.php

View File

@ -8,9 +8,9 @@
<directory suffix=".php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</include>
</coverage>
</phpunit>

35
rector.php Normal file
View File

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
use Rector\Core\Configuration\Option;
use Rector\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::AUTO_IMPORT_NAMES, true);
$parameters->set(Option::SETS, [
SetList::ACTION_INJECTION_TO_CONSTRUCTOR_INJECTION,
SetList::ARRAY_STR_FUNCTIONS_TO_STATIC_CALL,
SetList::CODE_QUALITY,
SetList::PHP_53,
SetList::PHP_54,
SetList::PHP_56,
SetList::PHP_70,
SetList::PHP_71,
SetList::PHP_72,
SetList::PHP_73,
SetList::PHPSTAN,
SetList::PHPUNIT_CODE_QUALITY,
SetList::SOLID,
]);
$parameters->set(Option::PATHS, [__DIR__ . '/src', __DIR__ . '/tests']);
$parameters->set(Option::EXCLUDE_RECTORS, [
StaticCallOnNonStaticToInstanceCallRector::class,
]);
};

View File

@ -1,16 +0,0 @@
# rector.yaml
parameters:
sets:
- 'action-injection-to-constructor-injection'
- 'array-str-functions-to-static-call'
- 'celebrity'
- 'doctrine'
- 'phpstan'
- 'phpunit-code-quality'
- 'solid'
- 'early-return'
- 'doctrine-code-quality'
- 'code-quality'
- 'php71'
- 'php72'
- 'php73'

View File

@ -1,79 +0,0 @@
<?php
declare(strict_types=1);
namespace Pest\Actions;
use Pest\Console\Coverage;
use Pest\Support\Str;
use Pest\TestSuite;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;
/**
* @internal
*/
final class AddsCoverage
{
/**
* @var string
*/
private const COVERAGE_OPTION = 'coverage';
/**
* @var string
*/
private const MIN_OPTION = 'min';
/**
* Holds the coverage related options.
*
* @var array<int, string>
*/
private const OPTIONS = [self::COVERAGE_OPTION, self::MIN_OPTION];
/**
* If any, adds the coverage params to the given original arguments.
*
* @param array<int, string> $originals
*
* @return array<int, string>
*/
public static function from(TestSuite $testSuite, array $originals): array
{
$arguments = array_merge([''], array_values(array_filter($originals, function ($original): bool {
foreach (self::OPTIONS as $option) {
if ($original === sprintf('--%s', $option) || Str::startsWith($original, sprintf('--%s=', $option))) {
return true;
}
}
return false;
})));
$originals = array_flip($originals);
foreach ($arguments as $argument) {
unset($originals[$argument]);
}
$originals = array_flip($originals);
$inputs = [];
$inputs[] = new InputOption(self::COVERAGE_OPTION, null, InputOption::VALUE_NONE);
$inputs[] = new InputOption(self::MIN_OPTION, null, InputOption::VALUE_REQUIRED);
$input = new ArgvInput($arguments, new InputDefinition($inputs));
if ((bool) $input->getOption(self::COVERAGE_OPTION)) {
$testSuite->coverage = true;
$originals[] = '--coverage-php';
$originals[] = Coverage::getPath();
}
if ($input->getOption(self::MIN_OPTION) !== null) {
/* @phpstan-ignore-next-line */
$testSuite->coverageMin = (float) $input->getOption(self::MIN_OPTION);
}
return $originals;
}
}

View File

@ -5,12 +5,16 @@ declare(strict_types=1);
namespace Pest\Actions;
use NunoMaduro\Collision\Adapters\Phpunit\Printer;
use Pest\TeamCity;
use PHPUnit\TextUI\DefaultResultPrinter;
/**
* @internal
*/
final class AddsDefaults
{
private const PRINTER = 'printer';
/**
* Adds default arguments to the given `arguments` array.
*
@ -20,8 +24,12 @@ final class AddsDefaults
*/
public static function to(array $arguments): array
{
if (!array_key_exists('printer', $arguments)) {
$arguments['printer'] = new Printer();
if (!array_key_exists(self::PRINTER, $arguments)) {
$arguments[self::PRINTER] = new Printer(null, $arguments['verbose'] ?? false, $arguments['colors'] ?? DefaultResultPrinter::COLOR_ALWAYS);
}
if ($arguments[self::PRINTER] === \PHPUnit\Util\Log\TeamCity::class) {
$arguments[self::PRINTER] = new TeamCity($arguments['verbose'] ?? false, $arguments['colors'] ?? DefaultResultPrinter::COLOR_ALWAYS);
}
return $arguments;

View File

@ -22,6 +22,7 @@ final class LoadStructure
*/
private const STRUCTURE = [
'Datasets.php',
'Helpers.php',
'Pest.php',
'Datasets',
];

View File

@ -6,8 +6,7 @@ namespace Pest\Actions;
use Pest\Exceptions\AttributeNotSupportedYet;
use Pest\Exceptions\FileOrFolderNotFound;
use PHPUnit\TextUI\Configuration\Configuration;
use PHPUnit\TextUI\Configuration\Registry;
use PHPUnit\TextUI\XmlConfiguration\Loader;
/**
* @internal
@ -30,9 +29,7 @@ final class ValidatesConfiguration
throw new FileOrFolderNotFound('phpunit.xml');
}
$configuration = Registry::getInstance()
->get($arguments[self::CONFIGURATION_KEY])
->phpunit();
$configuration = (new Loader())->load($arguments[self::CONFIGURATION_KEY])->phpunit();
if ($configuration->processIsolation()) {
throw new AttributeNotSupportedYet('processIsolation', 'true');

View File

@ -19,7 +19,6 @@ final class ValidatesEnvironment
*/
private const NEEDED_FILES = [
'composer.json',
'tests',
];
/**

View File

@ -5,9 +5,11 @@ declare(strict_types=1);
namespace Pest\Concerns;
use Closure;
use Pest\Expectation;
use Pest\Support\ExceptionTrace;
use Pest\TestSuite;
use PHPUnit\Util\Test;
use Throwable;
/**
* To avoid inheritance conflicts, all the fields related
@ -63,6 +65,11 @@ trait TestCase
return $this->__description;
}
public static function __getFileName(): string
{
return self::$__filename;
}
/**
* This method is called before the first test of this test class is run.
*/
@ -87,6 +94,16 @@ trait TestCase
parent::tearDownAfterClass();
}
/**
* Creates a new expectation.
*
* @param mixed $value
*/
public function expect($value): Expectation
{
return new Expectation($value);
}
/**
* Gets executed before the test.
*/
@ -129,16 +146,25 @@ trait TestCase
/**
* Runs the test.
*
* @return mixed
*
* @throws Throwable
*/
public function __test(): void
public function __test()
{
$this->__callClosure($this->__test, func_get_args());
return $this->__callClosure($this->__test, func_get_args());
}
private function __callClosure(Closure $closure, array $arguments): void
/**
* @return mixed
*
* @throws Throwable
*/
private function __callClosure(Closure $closure, array $arguments)
{
ExceptionTrace::ensure(function () use ($closure, $arguments) {
call_user_func_array(Closure::bind($closure, $this, get_class($this)), $arguments);
return ExceptionTrace::ensure(function () use ($closure, $arguments) {
return call_user_func_array(Closure::bind($closure, $this, get_class($this)), $arguments);
});
}

View File

@ -4,11 +4,15 @@ declare(strict_types=1);
namespace Pest\Console;
use Pest\Actions\AddsCoverage;
use Pest\Actions\AddsDefaults;
use Pest\Actions\AddsTests;
use Pest\Actions\LoadStructure;
use Pest\Actions\ValidatesConfiguration;
use Pest\Contracts\Plugins\AddsOutput;
use Pest\Contracts\Plugins\HandlesArguments;
use Pest\Plugin\Loader;
use Pest\Plugins\Version;
use Pest\Support\Container;
use Pest\TestSuite;
use PHPUnit\Framework\TestSuite as BaseTestSuite;
use PHPUnit\TextUI\Command as BaseCommand;
@ -54,9 +58,14 @@ final class Command extends BaseCommand
protected function handleArguments(array $argv): void
{
/*
* First, let's handle pest is own `--coverage` param.
* First, let's call all plugins that want to handle arguments
*/
$argv = AddsCoverage::from($this->testSuite, $argv);
$plugins = Loader::getPlugins(HandlesArguments::class);
/** @var HandlesArguments $plugin */
foreach ($plugins as $plugin) {
$argv = $plugin->handleArguments($argv);
}
/*
* Next, as usual, let's send the console arguments to PHPUnit.
@ -81,6 +90,8 @@ final class Command extends BaseCommand
*/
$this->arguments = AddsDefaults::to($this->arguments);
LoadStructure::in($this->testSuite->rootPath);
$testRunner = new TestRunner($this->arguments['loader']);
$testSuite = $this->arguments['test'];
@ -102,7 +113,6 @@ final class Command extends BaseCommand
$this->arguments['test'] = $testSuite;
}
LoadStructure::in($this->testSuite->rootPath);
AddsTests::to($testSuite, $this->testSuite);
return $testRunner;
@ -119,27 +129,24 @@ final class Command extends BaseCommand
{
$result = parent::run($argv, false);
if ($result === 0 && $this->testSuite->coverage) {
if (!Coverage::isAvailable()) {
$this->output->writeln(
"\n <fg=white;bg=red;options=bold> ERROR </> No code coverage driver is available.</>",
);
exit(1);
}
/*
* Let's call all plugins that want to add output after test execution
*/
$plugins = Loader::getPlugins(AddsOutput::class);
$coverage = Coverage::report($this->output);
$result = (int) ($coverage < $this->testSuite->coverageMin);
if ($result === 1) {
$this->output->writeln(sprintf(
"\n <fg=white;bg=red;options=bold> FAIL </> Code coverage below expected:<fg=red;options=bold> %s %%</>. Minimum:<fg=white;options=bold> %s %%</>.",
number_format($coverage, 1),
number_format($this->testSuite->coverageMin, 1)
));
}
/** @var AddsOutput $plugin */
foreach ($plugins as $plugin) {
$result = $plugin->addOutput($result);
}
exit($result);
}
protected function showHelp(): void
{
/** @var Version $version */
$version = Container::getInstance()->get(Version::class);
$version->handleArguments(['--version']);
parent::showHelp();
}
}

View File

@ -1,167 +0,0 @@
<?php
declare(strict_types=1);
namespace Pest\Console;
use Pest\Exceptions\ShouldNotHappen;
use SebastianBergmann\CodeCoverage\Node\Directory;
use SebastianBergmann\CodeCoverage\Node\File;
use SebastianBergmann\Environment\Runtime;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Terminal;
/**
* @internal
*/
final class Coverage
{
/**
* Returns the coverage path.
*/
public static function getPath(): string
{
return implode(DIRECTORY_SEPARATOR, [
dirname(__DIR__, 2),
'.temp',
'coverage.php',
]);
}
/**
* Runs true there is any code
* coverage driver available.
*/
public static function isAvailable(): bool
{
return (new Runtime())->canCollectCodeCoverage();
}
/**
* Reports the code coverage report to the
* console and returns the result in float.
*/
public static function report(OutputInterface $output): float
{
if (!file_exists($reportPath = self::getPath())) {
throw ShouldNotHappen::fromMessage(sprintf('Coverage not found in path: %s.', $reportPath));
}
/** @var \SebastianBergmann\CodeCoverage\CodeCoverage $codeCoverage */
$codeCoverage = require $reportPath;
unlink($reportPath);
$totalWidth = (new Terminal())->getWidth();
$dottedLineLength = $totalWidth <= 70 ? $totalWidth : 70;
$totalCoverage = $codeCoverage->getReport()->getLineExecutedPercent();
$output->writeln(
sprintf(
' <fg=white;options=bold>Cov: </><fg=default>%s</>',
$totalCoverage
)
);
$output->writeln('');
/** @var Directory<File|Directory> $report */
$report = $codeCoverage->getReport();
foreach ($report->getIterator() as $file) {
if (!$file instanceof File) {
continue;
}
$dirname = dirname($file->getId());
$basename = basename($file->getId(), '.php');
$name = $dirname === '.' ? $basename : implode(DIRECTORY_SEPARATOR, [
$dirname,
$basename,
]);
$rawName = $dirname === '.' ? $basename : implode(DIRECTORY_SEPARATOR, [
$dirname,
$basename,
]);
$linesExecutedTakenSize = 0;
if ($file->getLineExecutedPercent() != '0.00%') {
$linesExecutedTakenSize = strlen($uncoveredLines = trim(implode(', ', self::getMissingCoverage($file)))) + 1;
$name .= sprintf(' <fg=red>%s</>', $uncoveredLines);
}
$percentage = $file->getNumExecutableLines() === 0
? '100.0'
: number_format((float) $file->getLineExecutedPercent(), 1, '.', '');
$takenSize = strlen($rawName . $percentage) + 4 + $linesExecutedTakenSize; // adding 3 space and percent sign
$percentage = sprintf(
'<fg=%s>%s</>',
$percentage === '100.0' ? 'green' : ($percentage === '0.0' ? 'red' : 'yellow'),
$percentage
);
$output->writeln(sprintf(' %s %s %s %%',
$name,
str_repeat('.', max($dottedLineLength - $takenSize, 1)),
$percentage
));
}
return (float) $totalCoverage;
}
/**
* Generates an array of missing coverage on the following format:.
*
* ```
* ['11', '20..25', '50', '60...80'];
* ```
*
* @param File $file
*
* @return array<int, string>
*/
public static function getMissingCoverage($file): array
{
$shouldBeNewLine = true;
$eachLine = function (array $array, array $tests, int $line) use (&$shouldBeNewLine): array {
if (count($tests) > 0) {
$shouldBeNewLine = true;
return $array;
}
if ($shouldBeNewLine) {
$array[] = (string) $line;
$shouldBeNewLine = false;
return $array;
}
$lastKey = count($array) - 1;
if (array_key_exists($lastKey, $array) && strpos($array[$lastKey], '..') !== false) {
[$from] = explode('..', $array[$lastKey]);
$array[$lastKey] = sprintf('%s..%s', $from, $line);
return $array;
}
$array[$lastKey] = sprintf('%s..%s', $array[$lastKey], $line);
return $array;
};
$array = [];
foreach (array_filter($file->getCoverageData(), 'is_array') as $line => $tests) {
$array = $eachLine($array, $tests, $line);
}
return $array;
}
}

66
src/Console/Thanks.php Normal file
View File

@ -0,0 +1,66 @@
<?php
declare(strict_types=1);
namespace Pest\Console;
use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
/**
* @internal
*/
final class Thanks
{
/** @var array<int, string> */
private const FUNDING_MESSAGES = [
'',
' - Star or contribute to Pest:',
' <options=bold>https://github.com/pestphp/pest</>',
' - Tweet something about Pest on Twitter:',
' <options=bold>https://twitter.com/pestphp</>',
' - Sponsor the creator:',
' <options=bold>https://github.com/sponsors/nunomaduro</>',
];
/** @var OutputInterface */
private $output;
public function __construct(OutputInterface $output)
{
$this->output = $output;
}
/**
* Asks the user to support Pest.
*/
public function __invoke(): void
{
$wantsToSupport = (new SymfonyQuestionHelper())->ask(
new ArrayInput([]),
$this->output,
new ConfirmationQuestion(
'Can you quickly <options=bold>star our GitHub repository</>? 🙏🏻',
true,
)
);
if ($wantsToSupport === true) {
if (PHP_OS_FAMILY == 'Darwin') {
exec('open https://github.com/pestphp/pest');
}
if (PHP_OS_FAMILY == 'Windows') {
exec('start https://github.com/pestphp/pest');
}
if (PHP_OS_FAMILY == 'Linux') {
exec('xdg-open https://github.com/pestphp/pest');
}
}
foreach (self::FUNDING_MESSAGES as $message) {
$this->output->writeln($message);
}
}
}

View File

@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace Pest\Contracts\Plugins;
/**
* @internal
*/
interface AddsOutput
{
/**
* Allows to add custom output after the test suite was executed.
*/
public function addOutput(int $testReturnCode): int;
}

View File

@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace Pest\Contracts\Plugins;
/**
* @internal
*/
interface HandlesArguments
{
/**
* Allows to handle custom command line arguments.
*
* PLEASE NOTE: it is necessary to remove any custom argument from the array
* because otherwise the application will complain about them
*
* @param array<int, string> $arguments
*
* @return array<int, string> the updated list of arguments
*/
public function handleArguments(array $arguments): array;
}

View File

@ -74,24 +74,45 @@ final class Datasets
$data = iterator_to_array($data);
}
$namedData = [];
foreach ($data as $values) {
$dataSetDescriptions = [];
$dataSetValues = [];
foreach ($data as $key => $values) {
$values = is_array($values) ? $values : [$values];
$name = $description . self::getDataSetDescription($values);
$namedData[$name] = $values;
$dataSetDescriptions[] = $description . self::getDataSetDescription($key, $values);
$dataSetValues[] = $values;
}
foreach (array_count_values($dataSetDescriptions) as $descriptionToCheck => $count) {
if ($count > 1) {
$index = 1;
foreach ($dataSetDescriptions as $i => $dataSetDescription) {
if ($dataSetDescription === $descriptionToCheck) {
$dataSetDescriptions[$i] .= sprintf(' #%d', $index++);
}
}
}
}
$namedData = [];
foreach ($dataSetDescriptions as $i => $dataSetDescription) {
$namedData[$dataSetDescription] = $dataSetValues[$i];
}
return $namedData;
}
/**
* @param int|string $key
* @param array<int, mixed> $data
*/
private static function getDataSetDescription(array $data): string
private static function getDataSetDescription($key, array $data): string
{
$exporter = new Exporter();
return \sprintf(' with (%s)', $exporter->shortenedRecursiveExport($data));
$nameInsert = is_string($key) ? \sprintf('data set "%s" ', $key) : '';
return \sprintf(' with %s(%s)', $nameInsert, $exporter->shortenedRecursiveExport($data));
}
}

538
src/Expectation.php Normal file
View File

@ -0,0 +1,538 @@
<?php
declare(strict_types=1);
namespace Pest;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\Constraint\Constraint;
/**
* @internal
*
* @property Expectation $not Creates the opposite expectation.
*/
final class Expectation
{
/**
* The expectation value.
*
* @readonly
*
* @var mixed
*/
public $value;
/**
* Creates a new expectation.
*
* @param mixed $value
*/
public function __construct($value)
{
$this->value = $value;
}
/**
* Creates a new expectation.
*
* @param mixed $value
*/
public function and($value): Expectation
{
return new self($value);
}
/**
* Creates the opposite expectation for the value.
*/
public function not(): OppositeExpectation
{
return new OppositeExpectation($this);
}
/**
* Asserts that two variables have the same type and
* value. Used on objects, it asserts that two
* variables reference the same object.
*
* @param mixed $expected
*/
public function toBe($expected): Expectation
{
Assert::assertSame($expected, $this->value);
return $this;
}
/**
* Asserts that the value is empty.
*/
public function toBeEmpty(): Expectation
{
Assert::assertEmpty($this->value);
return $this;
}
/**
* Asserts that the value is true.
*/
public function toBeTrue(): Expectation
{
Assert::assertTrue($this->value);
return $this;
}
/**
* Asserts that the value is false.
*/
public function toBeFalse(): Expectation
{
Assert::assertFalse($this->value);
return $this;
}
/**
* Asserts that the value is greater than $expected.
*
* @param int|float $expected
*/
public function toBeGreaterThan($expected): Expectation
{
Assert::assertGreaterThan($expected, $this->value);
return $this;
}
/**
* Asserts that the value is greater than or equal to $expected.
*
* @param int|float $expected
*/
public function toBeGreaterThanOrEqual($expected): Expectation
{
Assert::assertGreaterThanOrEqual($expected, $this->value);
return $this;
}
/**
* Asserts that the value is less than or equal to $expected.
*
* @param int|float $expected
*/
public function toBeLessThan($expected): Expectation
{
Assert::assertLessThan($expected, $this->value);
return $this;
}
/**
* Asserts that the value is less than $expected.
*
* @param int|float $expected
*/
public function toBeLessThanOrEqual($expected): Expectation
{
Assert::assertLessThanOrEqual($expected, $this->value);
return $this;
}
/**
* Asserts that $needle is an element of the value.
*
* @param mixed $needle
*/
public function toContain($needle): Expectation
{
if (is_string($this->value)) {
Assert::assertStringContainsString($needle, $this->value);
} else {
Assert::assertContains($needle, $this->value);
}
return $this;
}
/**
* Asserts that the value starts with $expected.
*/
public function toStartWith(string $expected): Expectation
{
Assert::assertStringStartsWith($expected, $this->value);
return $this;
}
/**
* Asserts that the value ends with $expected.
*/
public function toEndWith(string $expected): Expectation
{
Assert::assertStringEndsWith($expected, $this->value);
return $this;
}
/**
* Asserts that $count matches the number of elements of the value.
*/
public function toHaveCount(int $count): Expectation
{
Assert::assertCount($count, $this->value);
return $this;
}
/**
* Asserts that the value contains the property $name.
*
* @param mixed $value
*/
public function toHaveProperty(string $name, $value = null): Expectation
{
$this->toBeObject();
Assert::assertTrue(property_exists($this->value, $name));
if (func_num_args() > 1) {
/* @phpstan-ignore-next-line */
Assert::assertEquals($value, $this->value->{$name});
}
return $this;
}
/**
* Asserts that two variables have the same value.
*
* @param mixed $expected
*/
public function toEqual($expected): Expectation
{
Assert::assertEquals($expected, $this->value);
return $this;
}
/**
* Asserts that two variables have the same value.
* The contents of $expected and the $this->value are
* canonicalized before they are compared. For instance, when the two
* variables $expected and $this->value are arrays, then these arrays
* are sorted before they are compared. When $expected and $this->value
* are objects, each object is converted to an array containing all
* private, protected and public attributes.
*
* @param mixed $expected
*/
public function toEqualCanonicalizing($expected): Expectation
{
Assert::assertEqualsCanonicalizing($expected, $this->value);
return $this;
}
/**
* Asserts that the absolute difference between the value and $expected
* is lower than $delta.
*
* @param mixed $expected
*/
public function toEqualWithDelta($expected, float $delta): Expectation
{
Assert::assertEqualsWithDelta($expected, $this->value, $delta);
return $this;
}
/**
* Asserts that the value is infinite.
*/
public function toBeInfinite(): Expectation
{
Assert::assertInfinite($this->value);
return $this;
}
/**
* Asserts that the value is an instance of $class.
*
* @param string $class
*/
public function toBeInstanceOf($class): Expectation
{
/* @phpstan-ignore-next-line */
Assert::assertInstanceOf($class, $this->value);
return $this;
}
/**
* Asserts that the value is an array.
*/
public function toBeArray(): Expectation
{
Assert::assertIsArray($this->value);
return $this;
}
/**
* Asserts that the value is of type bool.
*/
public function toBeBool(): Expectation
{
Assert::assertIsBool($this->value);
return $this;
}
/**
* Asserts that the value is of type callable.
*/
public function toBeCallable(): Expectation
{
Assert::assertIsCallable($this->value);
return $this;
}
/**
* Asserts that the value is of type float.
*/
public function toBeFloat(): Expectation
{
Assert::assertIsFloat($this->value);
return $this;
}
/**
* Asserts that the value is of type int.
*/
public function toBeInt(): Expectation
{
Assert::assertIsInt($this->value);
return $this;
}
/**
* Asserts that the value is of type iterable.
*/
public function toBeIterable(): Expectation
{
Assert::assertIsIterable($this->value);
return $this;
}
/**
* Asserts that the value is of type numeric.
*/
public function toBeNumeric(): Expectation
{
Assert::assertIsNumeric($this->value);
return $this;
}
/**
* Asserts that the value is of type object.
*/
public function toBeObject(): Expectation
{
Assert::assertIsObject($this->value);
return $this;
}
/**
* Asserts that the value is of type resource.
*/
public function toBeResource(): Expectation
{
Assert::assertIsResource($this->value);
return $this;
}
/**
* Asserts that the value is of type scalar.
*/
public function toBeScalar(): Expectation
{
Assert::assertIsScalar($this->value);
return $this;
}
/**
* Asserts that the value is of type string.
*/
public function toBeString(): Expectation
{
Assert::assertIsString($this->value);
return $this;
}
/**
* Asserts that the value is NAN.
*/
public function toBeNan(): Expectation
{
Assert::assertNan($this->value);
return $this;
}
/**
* Asserts that the value is null.
*/
public function toBeNull(): Expectation
{
Assert::assertNull($this->value);
return $this;
}
/**
* Asserts that the value array has the provided $key.
*
* @param string|int $key
*/
public function toHaveKey($key): Expectation
{
Assert::assertArrayHasKey($key, $this->value);
return $this;
}
/**
* Asserts that the value array has the provided $keys.
*
* @param array<int, int|string> $keys
*/
public function toHaveKeys(array $keys): Expectation
{
foreach ($keys as $key) {
$this->toHaveKey($key);
}
return $this;
}
/**
* Asserts that the value is a directory.
*/
public function toBeDirectory(): Expectation
{
Assert::assertDirectoryExists($this->value);
return $this;
}
/**
* Asserts that the value is a directory and is readable.
*/
public function toBeReadableDirectory(): Expectation
{
Assert::assertDirectoryIsReadable($this->value);
return $this;
}
/**
* Asserts that the value is a directory and is writable.
*/
public function toBeWritableDirectory(): Expectation
{
Assert::assertDirectoryIsWritable($this->value);
return $this;
}
/**
* Asserts that the value is a file.
*/
public function toBeFile(): Expectation
{
Assert::assertFileExists($this->value);
return $this;
}
/**
* Asserts that the value is a file and is readable.
*/
public function toBeReadableFile(): Expectation
{
Assert::assertFileIsReadable($this->value);
return $this;
}
/**
* Asserts that the value is a file and is writable.
*/
public function toBeWritableFile(): Expectation
{
Assert::assertFileIsWritable($this->value);
return $this;
}
/**
* Asserts that the value object matches a subset
* of the properties of an given object.
*
* @param array<string, mixed>|object $object
*/
public function toMatchObject($object): Expectation
{
foreach ((array) $object as $property => $value) {
$this->toHaveProperty($property, $value);
}
return $this;
}
/**
* Asserts that the value matches a regular expression.
*/
public function toMatch(string $expression): Expectation
{
Assert::assertMatchesRegularExpression($expression, $this->value);
return $this;
}
/**
* Asserts that the value matches a constraint.
*/
public function toMatchConstraint(Constraint $constraint): Expectation
{
Assert::assertThat($this->value, $constraint);
return $this;
}
/**
* Dynamically calls methods on the class without any arguments.
*
* @return Expectation
*/
public function __get(string $name)
{
/* @phpstan-ignore-next-line */
return $this->{$name}();
}
}

View File

@ -8,6 +8,7 @@ use Closure;
use Pest\Concerns;
use Pest\Contracts\HasPrintableTestCaseName;
use Pest\Datasets;
use Pest\Exceptions\ShouldNotHappen;
use Pest\Support\HigherOrderMessageCollection;
use Pest\Support\NullClosure;
use Pest\TestSuite;
@ -39,9 +40,10 @@ final class TestCaseFactory
/**
* Holds the test description.
*
* @readonly
* If the description is null, means that it
* will be created with the given assertions.
*
* @var string
* @var string|null
*/
public $description;
@ -104,7 +106,7 @@ final class TestCaseFactory
/**
* Creates a new anonymous test case pending object.
*/
public function __construct(string $filename, string $description, Closure $closure = null)
public function __construct(string $filename, string $description = null, Closure $closure = null)
{
$this->filename = $filename;
$this->description = $description;
@ -122,14 +124,22 @@ final class TestCaseFactory
*/
public function build(TestSuite $testSuite): array
{
if ($this->description === null) {
throw ShouldNotHappen::fromMessage('Description can not be empty.');
}
$chains = $this->chains;
$proxies = $this->proxies;
$factoryTest = $this->test;
$test = function () use ($chains, $proxies, $factoryTest): void {
/**
* @return mixed
*/
$test = function () use ($chains, $proxies, $factoryTest) {
$proxies->proxy($this);
$chains->chain($this);
call_user_func(Closure::bind($factoryTest, $this, get_class($this)), ...func_get_args());
return call_user_func(Closure::bind($factoryTest, $this, get_class($this)), ...func_get_args());
};
$className = $this->makeClassFromFilename($this->filename);
@ -147,21 +157,37 @@ final class TestCaseFactory
}
/**
* Makes a fully qualified class name
* from the given filename.
* Makes a fully qualified class name from the current filename.
*/
public function getClassName(): string
{
return $this->makeClassFromFilename($this->filename);
}
/**
* Makes a fully qualified class name from the given filename.
*/
public function makeClassFromFilename(string $filename): string
{
if ('\\' === DIRECTORY_SEPARATOR) {
// In case Windows, strtolower drive name, like in UsesCall.
$filename = (string) preg_replace_callback('~^(?P<drive>[a-z]+:\\\)~i', function ($match): string {
return strtolower($match['drive']);
}, $filename);
}
$filename = (string) realpath($filename);
$rootPath = TestSuite::getInstance()->rootPath;
$relativePath = str_replace($rootPath . DIRECTORY_SEPARATOR, '', $filename);
$relativePath = dirname(ucfirst($relativePath)) . DIRECTORY_SEPARATOR . basename($relativePath, '.php');
$relativePath = str_replace(DIRECTORY_SEPARATOR, '\\', $relativePath);
// Strip out any %-encoded octets.
$relativePath = (string) preg_replace('|%[a-fA-F0-9][a-fA-F0-9]|', '', $relativePath);
// Limit to A-Z, a-z, 0-9, '_', '-'.
$relativePath = (string) preg_replace('/[^A-Za-z0-9.\/]/', '', $relativePath);
$classFQN = 'P\\' . basename(ucfirst(str_replace(DIRECTORY_SEPARATOR, '\\', $relativePath)), '.php');
$relativePath = (string) preg_replace('/[^A-Za-z0-9.\\\]/', '', $relativePath);
$classFQN = 'P\\' . $relativePath;
if (class_exists($classFQN)) {
return $classFQN;
}

View File

@ -61,7 +61,8 @@ final class PestDatasetCommand extends Command
$element = Str::singular($name);
$contents = str_replace('{dataset_element}', $element, $contents);
File::put($target, str_replace('{dataset_name}', $name, $contents));
$message = sprintf('`%s` created successfully.', $relativePath);
$this->output->success(sprintf('`%s` created successfully.', $relativePath));
$this->output->success($message);
}
}

View File

@ -6,7 +6,9 @@ namespace Pest\Laravel\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
use Pest\Console\Thanks;
use Pest\Exceptions\InvalidConsoleArgument;
use Pest\Support\Str;
/**
* @internal
@ -33,18 +35,43 @@ final class PestInstallCommand extends Command
public function handle(): void
{
/* @phpstan-ignore-next-line */
$target = base_path('tests/Pest.php');
$pest = base_path('tests/Pest.php');
/* @phpstan-ignore-next-line */
$helpers = base_path('tests/Helpers.php');
$stubs = $this->isLumen() ? 'stubs/Lumen' : 'stubs/Laravel';
if (File::exists($target)) {
throw new InvalidConsoleArgument(sprintf('%s already exist', $target));
foreach ([$pest, $helpers] as $file) {
if (File::exists($file)) {
throw new InvalidConsoleArgument(sprintf('%s already exist', $file));
}
}
File::copy(implode(DIRECTORY_SEPARATOR, [
dirname(__DIR__, 3),
'stubs',
$stubs,
'Pest.php',
]), $target);
]), $pest);
File::copy(implode(DIRECTORY_SEPARATOR, [
dirname(__DIR__, 3),
$stubs,
'Helpers.php',
]), $helpers);
$this->output->success('`tests/Pest.php` created successfully.');
$this->output->success('`tests/Helpers.php` created successfully.');
if (!(bool) $this->option('no-interaction')) {
(new Thanks($this->output))();
}
}
/**
* Determine if this is a Lumen application.
*/
private function isLumen(): bool
{
/* @phpstan-ignore-next-line */
return Str::startsWith(app()->version(), 'Lumen');
}
}

View File

@ -64,7 +64,8 @@ final class PestTestCommand extends Command
$name = Str::endsWith($name, 'test') ? mb_substr($name, 0, -4) : $name;
File::put($target, str_replace('{name}', $name, $contents));
$message = sprintf('`%s` created successfully.', $relativePath);
$this->output->success(sprintf('`%s` created successfully.', $relativePath));
$this->output->success($message);
}
}

100
src/OppositeExpectation.php Normal file
View File

@ -0,0 +1,100 @@
<?php
declare(strict_types=1);
namespace Pest;
use PHPUnit\Framework\ExpectationFailedException;
use SebastianBergmann\Exporter\Exporter;
/**
* @internal
*
* @mixin Expectation
*/
final class OppositeExpectation
{
/**
* @var Expectation
*/
private $original;
/**
* Creates a new opposite expectation.
*/
public function __construct(Expectation $original)
{
$this->original = $original;
}
/**
* Asserts that the value array not has the provided $keys.
*
* @param array<int, int|string> $keys
*/
public function toHaveKeys(array $keys): Expectation
{
foreach ($keys as $key) {
try {
$this->original->toHaveKey($key);
} catch (ExpectationFailedException $e) {
continue;
}
$this->throwExpectationFailedExpection('toHaveKey', [$key]);
}
return $this->original;
}
/**
* Handle dynamic method calls into the original expectation.
*
* @param array<int, mixed> $arguments
*/
public function __call(string $name, array $arguments): Expectation
{
try {
/* @phpstan-ignore-next-line */
$this->original->{$name}(...$arguments);
} catch (ExpectationFailedException $e) {
return $this->original;
}
// @phpstan-ignore-next-line
$this->throwExpectationFailedExpection($name, $arguments);
}
/**
* Handle dynamic properties gets into the original expectation.
*/
public function __get(string $name): Expectation
{
try {
/* @phpstan-ignore-next-line */
$this->original->{$name};
} catch (ExpectationFailedException $e) {
return $this->original;
}
// @phpstan-ignore-next-line
$this->throwExpectationFailedExpection($name);
}
/**
* Creates a new expectation failed exception
* with a nice readable message.
*
* @param array<int, mixed> $arguments
*/
private function throwExpectationFailedExpection(string $name, array $arguments = []): void
{
$exporter = new Exporter();
$toString = function ($argument) use ($exporter): string {
return $exporter->shortenedExport($argument);
};
throw new ExpectationFailedException(sprintf('Expecting %s not %s %s.', $toString($this->original->value), strtolower((string) preg_replace('/(?<!\ )[A-Z]/', ' $0', $name)), implode(' ', array_map(function ($argument) use ($toString): string { return $toString($argument); }, $arguments))));
}
}

View File

@ -9,12 +9,25 @@ use Pest\Factories\TestCaseFactory;
use Pest\Support\Backtrace;
use Pest\Support\NullClosure;
use Pest\TestSuite;
use PHPUnit\Framework\ExecutionOrderDependency;
use SebastianBergmann\Exporter\Exporter;
/**
* @method \Pest\Expectation expect(mixed $value)
*
* @internal
*/
final class TestCall
{
/**
* Holds the test suite.
*
* @readonly
*
* @var TestSuite
*/
private $testSuite;
/**
* Holds the test case factory.
*
@ -24,14 +37,23 @@ final class TestCall
*/
private $testCaseFactory;
/**
* If test call is descriptionLess.
*
* @readonly
*
* @var bool
*/
private $descriptionLess = false;
/**
* Creates a new instance of a pending test call.
*/
public function __construct(TestSuite $testSuite, string $filename, string $description, Closure $closure = null)
public function __construct(TestSuite $testSuite, string $filename, string $description = null, Closure $closure = null)
{
$this->testCaseFactory = new TestCaseFactory($filename, $description, $closure);
$testSuite->tests->set($this->testCaseFactory);
$this->testSuite = $testSuite;
$this->descriptionLess = $description === null;
}
/**
@ -40,13 +62,13 @@ final class TestCall
public function throws(string $exceptionClass, string $exceptionMessage = null): TestCall
{
$this->testCaseFactory
->proxies
->add(Backtrace::file(), Backtrace::line(), 'expectException', [$exceptionClass]);
->proxies
->add(Backtrace::file(), Backtrace::line(), 'expectException', [$exceptionClass]);
if (is_string($exceptionMessage)) {
$this->testCaseFactory
->proxies
->add(Backtrace::file(), Backtrace::line(), 'expectExceptionMessage', [$exceptionMessage]);
->proxies
->add(Backtrace::file(), Backtrace::line(), 'expectExceptionMessage', [$exceptionMessage]);
}
return $this;
@ -65,6 +87,24 @@ final class TestCall
return $this;
}
/**
* Sets the test depends.
*/
public function depends(string ...$tests): TestCall
{
$className = $this->testCaseFactory->getClassName();
$tests = array_map(function (string $test) use ($className): ExecutionOrderDependency {
return ExecutionOrderDependency::createFromDependsAnnotation($className, $test);
}, $tests);
$this->testCaseFactory
->factoryProxies
->add(Backtrace::file(), Backtrace::line(), 'setDependencies', [$tests]);
return $this;
}
/**
* Makes the test suite only this test case.
*/
@ -76,13 +116,13 @@ final class TestCall
}
/**
* Sets the test groups(s).
* Sets the test group(s).
*/
public function group(string ...$groups): TestCall
{
$this->testCaseFactory
->factoryProxies
->add(Backtrace::file(), Backtrace::line(), 'addGroups', [$groups]);
->factoryProxies
->add(Backtrace::file(), Backtrace::line(), 'addGroups', [$groups]);
return $this;
}
@ -110,8 +150,8 @@ final class TestCall
if ($condition() !== false) {
$this->testCaseFactory
->chains
->add(Backtrace::file(), Backtrace::line(), 'markTestSkipped', [$message]);
->chains
->add(Backtrace::file(), Backtrace::line(), 'markTestSkipped', [$message]);
}
return $this;
@ -125,9 +165,26 @@ final class TestCall
public function __call(string $name, array $arguments): self
{
$this->testCaseFactory
->chains
->add(Backtrace::file(), Backtrace::line(), $name, $arguments);
->chains
->add(Backtrace::file(), Backtrace::line(), $name, $arguments);
if ($this->descriptionLess) {
$exporter = new Exporter();
if ($this->testCaseFactory->description !== null) {
$this->testCaseFactory->description .= ' → ';
}
$this->testCaseFactory->description .= sprintf('%s %s', $name, $exporter->shortenedRecursiveExport($arguments));
}
return $this;
}
/**
* Adds the current test case factory
* to the tests repository.
*/
public function __destruct()
{
$this->testSuite->tests->set($this->testCaseFactory);
}
}

View File

@ -59,7 +59,17 @@ final class UsesCall
public function in(string ...$targets): void
{
$targets = array_map(function ($path): string {
return $path[0] === DIRECTORY_SEPARATOR
$startChar = DIRECTORY_SEPARATOR;
if ('\\' === DIRECTORY_SEPARATOR || preg_match('~\A[A-Z]:(?![^/\\\\])~i', $path) > 0) {
$path = (string) preg_replace_callback('~^(?P<drive>[a-z]+:\\\)~i', function ($match): string {
return strtolower($match['drive']);
}, $path);
$startChar = strtolower((string) preg_replace('~^([a-z]+:\\\).*$~i', '$1', __DIR__));
}
return 0 === strpos($path, $startChar)
? $path
: implode(DIRECTORY_SEPARATOR, [
dirname($this->filename),
@ -68,12 +78,12 @@ final class UsesCall
}, $targets);
$this->targets = array_map(function ($target): string {
$realTarget = realpath($target);
if ($realTarget === false) {
$isValid = is_dir($target) || file_exists($target);
if (!$isValid) {
throw new InvalidUsesPath($target);
}
return $realTarget;
return (string) realpath($target);
}, $targets);
}

10
src/Pest.php Normal file
View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Pest;
function version(): string
{
return '0.3.11';
}

28
src/Plugin.php Normal file
View File

@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace Pest;
final class Plugin
{
/**
* The lazy callables to be executed
* once the test suite boots.
*
* @var array<int, callable>
*
* @internal
*/
public static $callables = [];
/**
* Lazy loads an `uses` call on the context of plugins.
*/
public static function uses(string ...$traits): void
{
self::$callables[] = function () use ($traits): void {
uses(...$traits)->in(TestSuite::getInstance()->rootPath . DIRECTORY_SEPARATOR . 'tests');
};
}
}

39
src/Plugins/Version.php Normal file
View File

@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace Pest\Plugins;
use Pest\Contracts\Plugins\HandlesArguments;
use function Pest\version;
use Symfony\Component\Console\Output\OutputInterface;
/**
* @internal
*/
final class Version implements HandlesArguments
{
/**
* @var OutputInterface
*/
private $output;
/**
* Creates a new instance of the plugin.
*/
public function __construct(OutputInterface $output)
{
$this->output = $output;
}
public function handleArguments(array $arguments): array
{
if (in_array('--version', $arguments, true)) {
$this->output->writeln(
sprintf('Pest %s', version()),
);
}
return $arguments;
}
}

View File

@ -41,6 +41,12 @@ final class AfterEachRepository
return ChainableClosure::from(function (): void {
if (class_exists(Mockery::class)) {
/* @phpstan-ignore-next-line */
if ($container = Mockery::getContainer()) {
/* @phpstan-ignore-next-line */
$this->addToAssertionCount($container->mockery_getExpectationCount());
}
Mockery::close();
}
}, $afterEach);

View File

@ -4,12 +4,14 @@ declare(strict_types=1);
namespace Pest\Repositories;
use Pest\Exceptions\ShouldNotHappen;
use Pest\Exceptions\TestAlreadyExist;
use Pest\Exceptions\TestCaseAlreadyInUse;
use Pest\Exceptions\TestCaseClassOrTraitNotFound;
use Pest\Factories\TestCaseFactory;
use Pest\Support\Str;
use Pest\TestSuite;
use PHPUnit\Framework\TestCase;
/**
* @internal
@ -51,10 +53,9 @@ final class TestRepository
if ((!is_dir($path) && $filename === $path) || (is_dir($path) && $startsWith($filename, $path))) {
foreach ($classOrTraits as $class) {
if (class_exists($class)) {
if ($testCase->class !== \PHPUnit\Framework\TestCase::class) {
if ($testCase->class !== TestCase::class) {
throw new TestCaseAlreadyInUse($testCase->class, $class, $filename);
}
$testCase->class = $class;
} elseif (trait_exists($class)) {
$testCase->traits[] = $class;
@ -62,9 +63,9 @@ final class TestRepository
}
$testCase
->factoryProxies
// Consider set the real line here.
->add($filename, 0, 'addGroups', [$groups]);
->factoryProxies
// Consider set the real line here.
->add($filename, 0, 'addGroups', [$groups]);
}
};
@ -104,7 +105,14 @@ final class TestRepository
}
foreach ($paths as $path) {
$this->uses[$path] = [$classOrTraits, $groups];
if (array_key_exists($path, $this->uses)) {
$this->uses[$path] = [
array_merge($this->uses[$path][0], $classOrTraits),
array_merge($this->uses[$path][1], $groups),
];
} else {
$this->uses[$path] = [$classOrTraits, $groups];
}
}
}
@ -113,6 +121,10 @@ final class TestRepository
*/
public function set(TestCaseFactory $test): void
{
if ($test->description === null) {
throw ShouldNotHappen::fromMessage('Trying to create a test without description.');
}
if (array_key_exists(sprintf('%s@%s', $test->filename, $test->description), $this->state)) {
throw new TestAlreadyExist($test->filename, $test->description);
}

View File

@ -4,17 +4,48 @@ declare(strict_types=1);
namespace Pest\Support;
use Pest\Exceptions\ShouldNotHappen;
/**
* @internal
*/
final class Backtrace
{
/**
* @var string
*/
private const FILE = 'file';
private const BACKTRACE_OPTIONS = DEBUG_BACKTRACE_IGNORE_ARGS;
/**
* Returns the current test file.
*/
public static function testFile(): string
{
$current = null;
foreach (debug_backtrace(self::BACKTRACE_OPTIONS) as $trace) {
if (Str::endsWith($trace[self::FILE], (string) realpath('vendor/phpunit/phpunit/src/Util/FileLoader.php'))) {
break;
}
$current = $trace;
}
if ($current === null) {
throw ShouldNotHappen::fromMessage('Test file not found.');
}
return $current[self::FILE];
}
/**
* Returns the filename that called the current function/method.
*/
public static function file(): string
{
return debug_backtrace()[1]['file'];
return debug_backtrace(self::BACKTRACE_OPTIONS)[1][self::FILE];
}
/**
@ -22,7 +53,7 @@ final class Backtrace
*/
public static function dirname(): string
{
return dirname(debug_backtrace()[1]['file']);
return dirname(debug_backtrace(self::BACKTRACE_OPTIONS)[1][self::FILE]);
}
/**
@ -30,6 +61,6 @@ final class Backtrace
*/
public static function line(): int
{
return debug_backtrace()[1]['line'];
return debug_backtrace(self::BACKTRACE_OPTIONS)[1]['line'];
}
}

102
src/Support/Container.php Normal file
View File

@ -0,0 +1,102 @@
<?php
declare(strict_types=1);
namespace Pest\Support;
use Pest\Exceptions\ShouldNotHappen;
use ReflectionClass;
use ReflectionParameter;
/**
* @internal
*/
final class Container
{
/**
* @var self
*/
private static $instance;
/**
* @var array<string, mixed>
*/
private $instances = [];
/**
* Gets a new or already existing container.
*/
public static function getInstance(): self
{
if (static::$instance === null) {
static::$instance = new static();
}
return static::$instance;
}
/**
* Gets a dependency from the container.
*
* @return object
*/
public function get(string $id)
{
if (array_key_exists($id, $this->instances)) {
return $this->instances[$id];
}
$this->instances[$id] = $this->build($id);
return $this->instances[$id];
}
/**
* Adds the given instance to the container.
*
* @param mixed $instance
*/
public function add(string $id, $instance): void
{
$this->instances[$id] = $instance;
}
/**
* Tries to build the given instance.
*/
private function build(string $id): object
{
/** @phpstan-ignore-next-line */
$reflectionClass = new ReflectionClass($id);
if ($reflectionClass->isInstantiable()) {
$constructor = $reflectionClass->getConstructor();
if ($constructor !== null) {
$params = array_map(
function (ReflectionParameter $param) use ($id) {
$candidate = Reflection::getParameterClassName($param);
if ($candidate === null) {
$type = $param->getType();
if ($type !== null && $type->isBuiltin()) {
$candidate = $param->getName();
} else {
throw ShouldNotHappen::fromMessage(sprintf('The type of `$%s` in `%s` cannot be determined.', $id, $param->getName()));
}
}
return $this->get($candidate);
},
$constructor->getParameters()
);
return $reflectionClass->newInstanceArgs($params);
}
return $reflectionClass->newInstance();
}
throw ShouldNotHappen::fromMessage(sprintf('A dependency with the name `%s` cannot be resolved.', $id));
}
}

View File

@ -17,11 +17,15 @@ final class ExceptionTrace
/**
* Ensures the given closure reports
* the good execution context.
*
* @return mixed
*
* @throws Throwable
*/
public static function ensure(Closure $closure): void
public static function ensure(Closure $closure)
{
try {
$closure();
return $closure();
} catch (Throwable $throwable) {
if (Str::startsWith($message = $throwable->getMessage(), self::UNDEFINED_METHOD)) {
$message = str_replace(self::UNDEFINED_METHOD, 'Call to undefined method ', $message);

View File

@ -76,13 +76,24 @@ final class HigherOrderMessage
Reflection::setPropertyValue($throwable, 'file', $this->filename);
Reflection::setPropertyValue($throwable, 'line', $this->line);
if ($throwable->getMessage() === sprintf(self::UNDEFINED_METHOD, $this->methodName)) {
/** @var \ReflectionClass $reflection */
$reflection = (new ReflectionClass($target))->getParentClass();
if ($throwable->getMessage() === self::getUndefinedMethodMessage($target, $this->methodName)) {
/** @var ReflectionClass $reflection */
$reflection = new ReflectionClass($target);
/* @phpstan-ignore-next-line */
$reflection = $reflection->getParentClass() ?: $reflection;
Reflection::setPropertyValue($throwable, 'message', sprintf('Call to undefined method %s::%s()', $reflection->getName(), $this->methodName));
}
throw $throwable;
}
}
private static function getUndefinedMethodMessage(object $target, string $methodName): string
{
if (\PHP_MAJOR_VERSION >= 8) {
return sprintf(sprintf(self::UNDEFINED_METHOD, sprintf('%s::%s()', get_class($target), $methodName)));
}
return sprintf(self::UNDEFINED_METHOD, $methodName);
}
}

View File

@ -30,7 +30,7 @@ final class HigherOrderMessageCollection
public function chain(object $target): void
{
foreach ($this->messages as $message) {
$target = $message->call($target);
$target = $message->call($target) ?? $target;
}
}

View File

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Pest\Support;
use ReflectionClass;
use Throwable;
/**
* @internal
@ -51,12 +52,12 @@ final class HigherOrderTapProxy
try {
// @phpstan-ignore-next-line
return $this->target->{$property};
} catch (\Throwable $throwable) {
} catch (Throwable $throwable) {
Reflection::setPropertyValue($throwable, 'file', Backtrace::file());
Reflection::setPropertyValue($throwable, 'line', Backtrace::line());
if (Str::startsWith($message = $throwable->getMessage(), self::UNDEFINED_PROPERTY)) {
/** @var \ReflectionClass $reflection */
/** @var ReflectionClass $reflection */
$reflection = (new ReflectionClass($this->target))->getParentClass();
Reflection::setPropertyValue($throwable, 'message', sprintf('Undefined property %s::$%s', $reflection->getName(), $property));
}

View File

@ -6,9 +6,12 @@ namespace Pest\Support;
use Closure;
use Pest\Exceptions\ShouldNotHappen;
use Pest\TestSuite;
use ReflectionClass;
use ReflectionException;
use ReflectionFunction;
use ReflectionNamedType;
use ReflectionParameter;
use ReflectionProperty;
/**
@ -27,11 +30,25 @@ final class Reflection
{
$reflectionClass = new ReflectionClass($object);
$reflectionMethod = $reflectionClass->getMethod($method);
try {
$reflectionMethod = $reflectionClass->getMethod($method);
$reflectionMethod->setAccessible(true);
$reflectionMethod->setAccessible(true);
return $reflectionMethod->invoke($object, ...$args);
return $reflectionMethod->invoke($object, ...$args);
} catch (ReflectionException $exception) {
if (method_exists($object, '__call')) {
return $object->__call($method, $args);
}
if (is_callable($method)) {
return Closure::fromCallable($method)->bindTo(
TestSuite::getInstance()->test
)(...$args);
}
throw $exception;
}
}
/**
@ -109,4 +126,32 @@ final class Reflection
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($object, $value);
}
/**
* Get the class name of the given parameter's type, if possible.
*
* @see https://github.com/laravel/framework/blob/v6.18.25/src/Illuminate/Support/Reflector.php
*/
public static function getParameterClassName(ReflectionParameter $parameter): ?string
{
$type = $parameter->getType();
if (!$type instanceof ReflectionNamedType || $type->isBuiltin()) {
return null;
}
$name = $type->getName();
if (($class = $parameter->getDeclaringClass()) instanceof ReflectionClass) {
if ($name === 'self') {
return $class->getName();
}
if ($name === 'parent' && ($parent = $class->getParentClass()) instanceof ReflectionClass) {
return $parent->getName();
}
}
return $name;
}
}

210
src/TeamCity.php Normal file
View File

@ -0,0 +1,210 @@
<?php
declare(strict_types=1);
namespace Pest;
use function getmypid;
use Pest\Concerns\TestCase;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestResult;
use PHPUnit\Framework\TestSuite;
use PHPUnit\Framework\Warning;
use PHPUnit\TextUI\DefaultResultPrinter;
use function round;
use function str_replace;
use Throwable;
final class TeamCity extends DefaultResultPrinter
{
private const PROTOCOL = 'pest_qn://';
private const NAME = 'name';
private const LOCATION_HINT = 'locationHint';
private const DURATION = 'duration';
private const TEST_SUITE_STARTED = 'testSuiteStarted';
private const TEST_SUITE_FINISHED = 'testSuiteFinished';
/** @var int */
private $flowId;
/** @var bool */
private $isSummaryTestCountPrinted = false;
/** @var \PHPUnit\Util\Log\TeamCity */
private $phpunitTeamCity;
public function __construct(bool $verbose, string $colors)
{
parent::__construct(null, $verbose, $colors, false, 80, false);
$this->phpunitTeamCity = new \PHPUnit\Util\Log\TeamCity(
null,
$verbose,
$colors,
false,
80,
false
);
}
public function printResult(TestResult $result): void
{
$this->printHeader($result);
$this->printFooter($result);
}
/** @phpstan-ignore-next-line */
public function startTestSuite(TestSuite $suite): void
{
$this->flowId = getmypid();
if (!$this->isSummaryTestCountPrinted) {
$this->printEvent(
'testCount',
['count' => $suite->count()]
);
$this->isSummaryTestCountPrinted = true;
}
$suiteName = $suite->getName();
if (file_exists($suiteName) || !method_exists($suiteName, '__getFileName')) {
$this->printEvent(
self::TEST_SUITE_STARTED, [
self::NAME => $suiteName,
self::LOCATION_HINT => self::PROTOCOL . $suiteName,
]);
return;
}
$fileName = $suiteName::__getFileName();
$this->printEvent(
self::TEST_SUITE_STARTED, [
self::NAME => substr($suiteName, 2),
self::LOCATION_HINT => self::PROTOCOL . $fileName,
]);
}
/** @phpstan-ignore-next-line */
public function endTestSuite(TestSuite $suite): void
{
$suiteName = $suite->getName();
if (file_exists($suiteName) || !method_exists($suiteName, '__getFileName')) {
$this->printEvent(
self::TEST_SUITE_FINISHED, [
self::NAME => $suiteName,
self::LOCATION_HINT => self::PROTOCOL . $suiteName,
]);
return;
}
$this->printEvent(
self::TEST_SUITE_FINISHED, [
self::NAME => substr($suiteName, 2),
]);
}
/**
* @param Test|TestCase $test
*/
public function startTest(Test $test): void
{
if (!TeamCity::isPestTest($test)) {
$this->phpunitTeamCity->startTest($test);
return;
}
$this->printEvent('testStarted', [
self::NAME => $test->getName(),
/* @phpstan-ignore-next-line */
self::LOCATION_HINT => self::PROTOCOL . $test->toString(),
]);
}
/**
* @param Test|TestCase $test
*/
public function endTest(Test $test, float $time): void
{
if (!TeamCity::isPestTest($test)) {
$this->phpunitTeamCity->endTest($test, $time);
return;
}
$this->printEvent('testFinished', [
self::NAME => $test->getName(),
self::DURATION => self::toMilliseconds($time),
]);
}
/**
* @param Test|TestCase $test
*/
public function addError(Test $test, Throwable $t, float $time): void
{
$this->phpunitTeamCity->addError($test, $t, $time);
}
/**
* @phpstan-ignore-next-line
*
* @param Test|TestCase $test
*/
public function addWarning(Test $test, Warning $e, float $time): void
{
$this->phpunitTeamCity->addWarning($test, $e, $time);
}
public function addFailure(Test $test, AssertionFailedError $e, float $time): void
{
$this->phpunitTeamCity->addFailure($test, $e, $time);
}
protected function writeProgress(string $progress): void
{
}
/**
* @param array<string, string|int> $params
*/
private function printEvent(string $eventName, array $params = []): void
{
$this->write("\n##teamcity[{$eventName}");
if ($this->flowId !== 0) {
$params['flowId'] = $this->flowId;
}
foreach ($params as $key => $value) {
$escapedValue = self::escapeValue((string) $value);
$this->write(" {$key}='{$escapedValue}'");
}
$this->write("]\n");
}
private static function escapeValue(string $text): string
{
return str_replace(
['|', "'", "\n", "\r", ']', '['],
['||', "|'", '|n', '|r', '|]', '|['],
$text
);
}
private static function toMilliseconds(float $time): int
{
return (int) round($time * 1000);
}
private static function isPestTest(Test $test): bool
{
return in_array(TestCase::class, class_uses($test), true);
}
}

View File

@ -10,6 +10,7 @@ use Pest\Repositories\AfterEachRepository;
use Pest\Repositories\BeforeAllRepository;
use Pest\Repositories\BeforeEachRepository;
use Pest\Repositories\TestRepository;
use PHPUnit\Framework\TestCase;
/**
* @internal
@ -19,7 +20,7 @@ final class TestSuite
/**
* Holds the current test case.
*
* @var \PHPUnit\Framework\TestCase|null
* @var TestCase|null
*/
public $test;
@ -30,20 +31,6 @@ final class TestSuite
*/
public $tests;
/**
* Whether should show the coverage or not.
*
* @var bool
*/
public $coverage = false;
/**
* The minimum coverage.
*
* @var float
*/
public $coverageMin = 0.0;
/**
* Holds the before each repository.
*
@ -97,7 +84,7 @@ final class TestSuite
$this->afterEach = new AfterEachRepository();
$this->afterAll = new AfterAllRepository();
$this->rootPath = $rootPath;
$this->rootPath = (string) realpath($rootPath);
}
/**
@ -106,7 +93,13 @@ final class TestSuite
public static function getInstance(string $rootPath = null): TestSuite
{
if (is_string($rootPath)) {
return self::$instance ?? self::$instance = new TestSuite($rootPath);
self::$instance = new TestSuite($rootPath);
foreach (Plugin::$callables as $callable) {
$callable();
}
return self::$instance;
}
if (self::$instance === null) {

View File

@ -3,6 +3,7 @@
declare(strict_types=1);
use Pest\Datasets;
use Pest\Expectation;
use Pest\PendingObjects\AfterEachCall;
use Pest\PendingObjects\BeforeEachCall;
use Pest\PendingObjects\TestCall;
@ -13,7 +14,7 @@ use Pest\TestSuite;
use PHPUnit\Framework\TestCase;
/**
* Runs the given closure after all tests in the current file.
* Runs the given closure before all tests in the current file.
*/
function beforeAll(Closure $closure): void
{
@ -43,8 +44,8 @@ function dataset(string $name, $dataset): void
}
/**
* The uses function adds the binds the
* given arguments to test closures.
* The uses function binds the given
* arguments to test closures.
*/
function uses(string ...$classAndTraits): UsesCall
{
@ -66,7 +67,7 @@ function test(string $description = null, Closure $closure = null)
return new HigherOrderTapProxy(TestSuite::getInstance()->test);
}
$filename = Backtrace::file();
$filename = Backtrace::testFile();
return new TestCall(TestSuite::getInstance(), $filename, $description, $closure);
}
@ -80,9 +81,9 @@ function test(string $description = null, Closure $closure = null)
*/
function it(string $description, Closure $closure = null): TestCall
{
$filename = Backtrace::file();
$description = sprintf('it %s', $description);
return new TestCall(TestSuite::getInstance(), $filename, sprintf('it %s', $description), $closure);
return test($description, $closure);
}
/**
@ -104,3 +105,15 @@ function afterAll(Closure $closure = null): void
{
TestSuite::getInstance()->afterAll->set($closure);
}
/**
* Creates a new expectation.
*
* @param mixed $value the Value
*
* @return Expectation
*/
function expect($value)
{
return test()->expect($value);
}

11
stubs/Laravel/Helpers.php Normal file
View File

@ -0,0 +1,11 @@
<?php
namespace Tests;
/**
* A basic assert example.
*/
function assertExample(): void
{
test()->assertTrue(true);
}

View File

@ -12,10 +12,10 @@
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./app</directory>
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</include>
</coverage>
</phpunit>

11
stubs/Lumen/Helpers.php Normal file
View File

@ -0,0 +1,11 @@
<?php
namespace Tests;
/**
* A basic assert example.
*/
function assertExample(): void
{
test()->assertTrue(true);
}

3
stubs/Lumen/Pest.php Normal file
View File

@ -0,0 +1,3 @@
<?php
uses(TestCase::class)->in(__DIR__);

17
stubs/Lumen/phpunit.xml Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Application Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./app</directory>
</include>
</coverage>
</phpunit>

View File

@ -0,0 +1,7 @@
PASS Tests\Fixtures\DirectoryWithTests\ExampleTest
✓ it example 1
PASS Tests\Fixtures\ExampleTest
✓ it example 2
Tests: 2 passed

View File

@ -0,0 +1,4 @@
PASS Tests\Fixtures\DirectoryWithTests\ExampleTest
✓ it example 1
Tests: 1 passed

View File

@ -0,0 +1,60 @@
PASS Tests\Playground
✓ basic
Tests: 1 passed
Time: 0.20s
Cov: 6.49%
Actions/AddsDefaults ........................................... 0.0 %
Actions/AddsTests .............................................. 0.0 %
Actions/LoadStructure .......................................... 0.0 %
Actions/ValidatesConfiguration ................................. 0.0 %
Actions/ValidatesEnvironment ................................... 0.0 %
Concerns/TestCase 40..54, 71..88, 123..126, 147 ............... 44.4 %
Console/Command ................................................ 0.0 %
Contracts/HasPrintableTestCaseName ............................. 0.0 %
Contracts/Plugins/AddsOutput ................................ 100.0 %
Contracts/Plugins/HandlesArguments .......................... 100.0 %
Datasets ....................................................... 0.0 %
Exceptions/AfterAllAlreadyExist ................................ 0.0 %
Exceptions/AfterEachAlreadyExist ............................... 0.0 %
Exceptions/AttributeNotSupportedYet ............................ 0.0 %
Exceptions/BeforeEachAlreadyExist .............................. 0.0 %
Exceptions/DatasetAlreadyExist ................................. 0.0 %
Exceptions/DatasetDoesNotExist ................................. 0.0 %
Exceptions/FileOrFolderNotFound ................................ 0.0 %
Exceptions/InvalidConsoleArgument .............................. 0.0 %
Exceptions/InvalidPestCommand .................................. 0.0 %
Exceptions/InvalidUsesPath ..................................... 0.0 %
Exceptions/ShouldNotHappen ..................................... 0.0 %
Exceptions/TestAlreadyExist .................................... 0.0 %
Exceptions/TestCaseAlreadyInUse ................................ 0.0 %
Exceptions/TestCaseClassOrTraitNotFound ........................ 0.0 %
Factories/TestCaseFactory 111..133, 141..204 ................... 8.2 %
Laravel/Commands/PestDatasetCommand ............................ 0.0 %
Laravel/Commands/PestInstallCommand ............................ 0.0 %
Laravel/Commands/PestTestCommand ............................... 0.0 %
Laravel/PestServiceProvider .................................... 0.0 %
PendingObjects/AfterEachCall ................................... 0.0 %
PendingObjects/BeforeEachCall .................................. 0.0 %
PendingObjects/TestCall ........................................ 0.0 %
PendingObjects/UsesCall ........................................ 0.0 %
Plugin ......................................................... 0.0 %
Repositories/AfterAllRepository ................................ 0.0 %
Repositories/AfterEachRepository 28..33 ....................... 60.0 %
Repositories/BeforeAllRepository ............................... 0.0 %
Repositories/BeforeEachRepository 26..31 ...................... 20.0 %
Repositories/TestRepository .................................... 0.0 %
Support/Backtrace .............................................. 0.0 %
Support/ChainableClosure .................................... 100.0 %
Support/Container .............................................. 0.0 %
Support/ExceptionTrace 25..32 ................................. 28.6 %
Support/HigherOrderMessage ..................................... 0.0 %
Support/HigherOrderMessageCollection 24..25, 33, 43 ........... 50.0 %
Support/HigherOrderTapProxy .................................... 0.0 %
Support/NullClosure ......................................... 100.0 %
Support/Reflection ............................................. 0.0 %
Support/Str .................................................... 0.0 %
TestSuite 80..87, 95..101, 105 ................................ 20.0 %
globals ........................................................ 0.0 %

View File

@ -0,0 +1,5 @@
PASS Tests\Fixtures\DirectoryWithTests\ExampleTest
it example 1
Tests: 1 passed

View File

@ -0,0 +1,5 @@
 PASS  Tests\Fixtures\DirectoryWithTests\ExampleTest
✓ it example 1
Tests: 1 passed

View File

@ -1,7 +1,222 @@
PASS Tests\CustomTestCase\PhpunitTest
PASS Tests\CustomTestCase\ExecutedTest
✓ that gets executed
PASS Tests\Expect\not
✓ not property calls
PASS Tests\Expect\toBe
✓ expect true → toBeTrue → and false → toBeFalse
✓ strict comparisons
✓ failures
✓ not failures
PASS Tests\Expect\toBeArray
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeBool
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeCallable
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeDirectory
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeEmpty
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeFalse
✓ strict comparisons
✓ failures
✓ not failures
PASS Tests\Expect\toBeFile
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeFloat
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeGreatherThan
✓ passes
✓ failures
✓ not failures
PASS Tests\Expect\toBeGreatherThanOrEqual
✓ passes
✓ failures
✓ not failures
PASS Tests\Expect\toBeInfinite
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeInstanceOf
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeInt
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeIterable
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeLessThan
✓ passes
✓ failures
✓ not failures
PASS Tests\Expect\toBeLessThanOrEqual
✓ passes
✓ failures
✓ not failures
PASS Tests\Expect\toBeNAN
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeNull
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeNumeric
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeObject
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeReadableDirectory
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeReadableFile
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeResource
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeScalar
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeString
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeTrue
✓ strict comparisons
✓ failures
✓ not failures
PASS Tests\Expect\toBeWritableDirectory
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeWritableFile
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toContain
✓ passes strings
✓ passes arrays
✓ failures
✓ not failures
PASS Tests\Expect\toEndWith
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toEqual
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toEqualCanonicalizing
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toEqualWithDelta
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toHaveCount
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toHaveKey
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toHaveKeys
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toHaveProperty
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toMatch
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toMatchConstraint
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toMatchObject
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toStartWith
✓ pass
✓ failures
✓ not failures
PASS Tests\Features\AfterAll
✓ deletes file after all
@ -24,7 +239,7 @@
✓ it sets arrays
✓ it gets bound to test case object with ('a')
✓ it gets bound to test case object with ('b')
✓ it truncates the description with (' fooo fooo fooo fooo fooo fooo fooo f...oo fooo')
✓ it truncates the description with ('FoooFoooFoooFoooFoooFoooFoooF...ooFooo')
✓ lazy datasets with (1)
✓ lazy datasets with (2)
✓ lazy datasets did the job right
@ -40,10 +255,20 @@
✓ eager wrapped registered datasets with (1)
✓ eager wrapped registered datasets with (2)
✓ eager registered wrapped datasets did the job right
lazy named datasets with ( bar object (...))
✓ named datasets with data set "one" (1)
✓ named datasets with data set "two" (2)
✓ named datasets did the job right
✓ lazy named datasets with (Bar Object (...))
✓ it creates unique test case names with ('Name 1', Pest\Plugin Object (), true) #1
✓ it creates unique test case names with ('Name 1', Pest\Plugin Object (), true) #2
✓ it creates unique test case names with ('Name 1', Pest\Plugin Object (), false)
✓ it creates unique test case names with ('Name 2', Pest\Plugin Object (), false)
✓ it creates unique test case names with ('Name 2', Pest\Plugin Object (), true)
✓ it creates unique test case names with ('Name 1', Pest\Plugin Object (), true) #3
✓ it creates unique test case names - count
PASS Tests\Features\Exceptions
✓ it gives access the the underlying expect exception
✓ it gives access the the underlying expectException
✓ it catch exceptions
✓ it catch exceptions and messages
@ -52,41 +277,52 @@
✓ it throws error if property do not exist
✓ it allows to call underlying protected/private methods
✓ it throws error if method do not exist
✓ it can forward unexpected calls to any global function
PASS Tests\Features\HigherOrderMessages
PASS Tests\Features\HigherOrderTests
✓ it proxies calls to object
✓ it is capable doing multiple assertions
PASS Tests\Features\It
✓ it is a test
✓ it is a higher order message test
PASS Tests\Features\Macro
✓ it can call chained macro method
✓ it will throw exception from call if no macro exists
PASS Tests\Features\Mocks
✓ it has bar
PASS Tests\Features\PendingHigherOrderTests
✓ get 'foo' → get 'bar' → expect true → toBeTrue
✓ get 'foo' → expect true → toBeTrue
WARN Tests\Features\Skip
✓ it do not skips
s it skips with truthy
s it skips with truthy condition by default
s it skips with message → skipped because bar
s it skips with truthy closure condition
- it skips with truthy
- it skips with truthy condition by default
- it skips with message → skipped because bar
- it skips with truthy closure condition
✓ it do not skips with falsy closure condition
s it skips with condition and messsage → skipped because foo
- it skips with condition and message → skipped because foo
- it skips when skip after assertion
PASS Tests\Features\Test
✓ a test
✓ higher order message test
PASS Tests\Fixtures\DirectoryWithTests\ExampleTest
✓ it example
✓ it example 1
PASS Tests\Fixtures\ExampleTest
✓ it example
✓ it example 2
PASS Tests\PHPUnit\CustomTestCase\UsesPerDirectory
✓ closure was bound to custom test case
✓ closure was bound to CustomTestCase
PASS Tests\PHPUnit\CustomTestCaseInSubFolders\SubFolder\SubFolder\UsesPerSubDirectory
✓ closure was bound to custom test case
✓ closure was bound to CustomTestCase
PASS Tests\PHPUnit\CustomTestCaseInSubFolders\SubFolder2\UsesPerFile
✓ custom traits can be used
@ -95,9 +331,9 @@
PASS Tests\Playground
✓ basic
PASS Tests\Unit\Actions\AddsCoverage
✓ it adds coverage if --coverage exist
✓ it adds coverage if --min exist
PASS Tests\Plugins\Traits
✓ it allows global uses
✓ it allows multiple global uses registered in the same path
PASS Tests\Unit\Actions\AddsDefaults
✓ it sets defaults
@ -112,12 +348,25 @@
✓ it throws exception when `process isolation` is true
✓ it do not throws exception when `process isolation` is false
PASS Tests\Unit\Console\Coverage
✓ it generates coverage based on file input
PASS Tests\Unit\Datasets
✓ it show the names of named datasets in their description
PASS Tests\Unit\Plugins\Version
✓ it outputs the version when --version is used
✓ it do not outputs version when --version is not used
PASS Tests\Unit\Support\Backtrace
✓ it gets file name from called file
PASS Tests\Unit\Support\Container
✓ it exists
✓ it gets an instance
✓ autowire
✓ it creates an instance and resolves parameters
✓ it creates an instance and resolves also sub parameters
✓ it can resolve builtin value types
✓ it cannot resolve a parameter without type
PASS Tests\Unit\Support\Reflection
✓ it gets file name from closure
✓ it gets property values
@ -128,9 +377,19 @@
PASS Tests\Visual\SingleTestOrDirectory
✓ allows to run a single test
✓ allows to run a directory
✓ it has ascii chars
✓ it disable decorating printer when colors is set to never
WARN Tests\Visual\Success
s visual snapshot of test suite on success
- visual snapshot of test suite on success
Tests: 6 skipped, 69 passed
Time: 2.63s
PASS Tests\Features\Depends
✓ first
✓ second
✓ depends
✓ depends with ...params
✓ depends with defined arguments
✓ depends run test only once
Tests: 7 skipped, 231 passed

View File

@ -3,3 +3,27 @@
if (class_exists(NunoMaduro\Collision\Provider::class)) {
(new NunoMaduro\Collision\Provider())->register();
}
trait PluginTrait
{
public function assertPluginTraitGotRegistered(): void
{
$this->assertTrue(true);
}
}
trait SecondPluginTrait
{
public function assertSecondPluginTraitGotRegistered(): void
{
$this->assertTrue(true);
}
}
Pest\Plugin::uses(PluginTrait::class);
Pest\Plugin::uses(SecondPluginTrait::class);
function _assertThat()
{
expect(true)->toBeTrue();
}

10
tests/Expect/not.php Normal file
View File

@ -0,0 +1,10 @@
<?php
test('not property calls', function () {
expect(true)
->toBeTrue()
->not()->toBeFalse()
->not->toBeFalse
->and(false)
->toBeFalse();
});

20
tests/Expect/toBe.php Normal file
View File

@ -0,0 +1,20 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
expect(true)->toBeTrue()->and(false)->toBeFalse();
test('strict comparisons', function () {
$nuno = new stdClass();
$dries = new stdClass();
expect($nuno)->toBe($nuno)->not->toBe($dries);
});
test('failures', function () {
expect(1)->toBe(2);
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(1)->not->toBe(1);
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,16 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect([1, 2, 3])->toBeArray();
expect('1, 2, 3')->not->toBeArray();
});
test('failures', function () {
expect(null)->toBeArray();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(['a', 'b', 'c'])->not->toBeArray();
})->throws(ExpectationFailedException::class);

16
tests/Expect/toBeBool.php Normal file
View File

@ -0,0 +1,16 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect(true)->toBeBool();
expect(0)->not->toBeBool();
});
test('failures', function () {
expect(null)->toBeBool();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(false)->not->toBeBool();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,18 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect(function () {})->toBeCallable();
expect(null)->not->toBeCallable();
});
test('failures', function () {
$hello = 5;
expect($hello)->toBeCallable();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(function () { return 42; })->not->toBeCallable();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,17 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
$temp = sys_get_temp_dir();
expect($temp)->toBeDirectory();
});
test('failures', function () {
expect('/random/path/whatever')->toBeDirectory();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect('.')->not->toBeDirectory();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,18 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect([])->toBeEmpty();
expect(null)->toBeEmpty();
});
test('failures', function () {
expect([1, 2])->toBeEmpty();
expect(' ')->toBeEmpty();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect([])->not->toBeEmpty();
expect(null)->not->toBeEmpty();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,15 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('strict comparisons', function () {
expect(false)->toBeFalse();
});
test('failures', function () {
expect('')->toBeFalse();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(false)->not->toBe(false);
})->throws(ExpectationFailedException::class);

23
tests/Expect/toBeFile.php Normal file
View File

@ -0,0 +1,23 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
beforeEach(function () {
touch($this->tempFile = sys_get_temp_dir() . '/fake.file');
});
afterEach(function () {
unlink($this->tempFile);
});
test('pass', function () {
expect($this->tempFile)->toBeFile();
});
test('failures', function () {
expect('/random/path/whatever.file')->toBeFile();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect($this->tempFile)->not->toBeFile();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,16 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect(1.0)->toBeFloat();
expect(1)->not->toBeFloat();
});
test('failures', function () {
expect(42)->toBeFloat();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(log(3))->not->toBeFloat();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,16 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('passes', function () {
expect(42)->toBeGreaterThan(41);
expect(4)->toBeGreaterThan(3.9);
});
test('failures', function () {
expect(4)->toBeGreaterThan(4);
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(5)->not->toBeGreaterThan(4);
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,16 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('passes', function () {
expect(42)->toBeGreaterThanOrEqual(41);
expect(4)->toBeGreaterThanOrEqual(4);
});
test('failures', function () {
expect(4)->toBeGreaterThanOrEqual(4.1);
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(5)->not->toBeGreaterThanOrEqual(5);
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,16 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect(log(0))->toBeInfinite();
expect(log(1))->not->toBeInfinite();
});
test('failures', function () {
expect(asin(2))->toBeInfinite();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(INF)->not->toBeInfinite();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,16 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect(new Exception())->toBeInstanceOf(Exception::class);
expect(new Exception())->not->toBeInstanceOf(RuntimeException::class);
});
test('failures', function () {
expect(new Exception())->toBeInstanceOf(RuntimeException::class);
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(new Exception())->not->toBeInstanceOf(Exception::class);
})->throws(ExpectationFailedException::class);

16
tests/Expect/toBeInt.php Normal file
View File

@ -0,0 +1,16 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect(42)->toBeInt();
expect(42.0)->not->toBeInt();
});
test('failures', function () {
expect(42.0)->toBeInt();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(6 * 7)->not->toBeInt();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,23 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect([])->toBeIterable();
expect(null)->not->toBeIterable();
});
test('failures', function () {
expect(42)->toBeIterable();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
function gen(): iterable
{
yield 1;
yield 2;
yield 3;
}
expect(gen())->not->toBeIterable();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,16 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('passes', function () {
expect(41)->toBeLessThan(42);
expect(4)->toBeLessThan(5);
});
test('failures', function () {
expect(4)->toBeLessThan(4);
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(5)->not->toBeLessThan(6);
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,16 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('passes', function () {
expect(41)->toBeLessThanOrEqual(42);
expect(4)->toBeLessThanOrEqual(4);
});
test('failures', function () {
expect(4)->toBeLessThanOrEqual(3.9);
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(5)->not->toBeLessThanOrEqual(5);
})->throws(ExpectationFailedException::class);

16
tests/Expect/toBeNAN.php Normal file
View File

@ -0,0 +1,16 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect(asin(2))->toBeNan();
expect(log(0))->not->toBeNan();
});
test('failures', function () {
expect(1)->toBeNan();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(acos(1.5))->not->toBeNan();
})->throws(ExpectationFailedException::class);

16
tests/Expect/toBeNull.php Normal file
View File

@ -0,0 +1,16 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect(null)->toBeNull();
expect('')->not->toBeNull();
});
test('failures', function () {
expect('hello')->toBeNull();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(null)->not->toBeNull();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,16 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect(42)->toBeNumeric();
expect('A')->not->toBeNumeric();
});
test('failures', function () {
expect(null)->toBeNumeric();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(6 * 7)->not->toBeNumeric();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,16 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect((object) ['a' => 1])->toBeObject();
expect(['a' => 1])->not->toBeObject();
});
test('failures', function () {
expect(null)->toBeObject();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect((object) 'ciao')->not->toBeObject();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,15 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect(sys_get_temp_dir())->toBeReadableDirectory();
});
test('failures', function () {
expect('/random/path/whatever')->toBeReadableDirectory();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(sys_get_temp_dir())->not->toBeReadableDirectory();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,23 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
beforeEach(function () {
touch($this->tempFile = sys_get_temp_dir() . '/fake.file');
});
afterEach(function () {
unlink($this->tempFile);
});
test('pass', function () {
expect($this->tempFile)->toBeReadableFile();
});
test('failures', function () {
expect('/random/path/whatever.file')->toBeReadableFile();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect($this->tempFile)->not->toBeReadableFile();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,22 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
$resource = tmpfile();
afterAll(function () use ($resource) {
fclose($resource);
});
test('pass', function () use ($resource) {
expect($resource)->toBeResource();
expect(null)->not->toBeResource();
});
test('failures', function () {
expect(null)->toBeResource();
})->throws(ExpectationFailedException::class);
test('not failures', function () use ($resource) {
expect($resource)->not->toBeResource();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,15 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect(1.1)->toBeScalar();
});
test('failures', function () {
expect(null)->toBeScalar();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(42)->not->toBeScalar();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,16 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect('1.1')->toBeString();
expect(1.1)->not->toBeString();
});
test('failures', function () {
expect(null)->toBeString();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect('42')->not->toBeString();
})->throws(ExpectationFailedException::class);

15
tests/Expect/toBeTrue.php Normal file
View File

@ -0,0 +1,15 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('strict comparisons', function () {
expect(true)->toBeTrue();
});
test('failures', function () {
expect('')->toBeTrue();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(false)->not->toBe(false);
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,15 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect(sys_get_temp_dir())->toBeWritableDirectory();
});
test('failures', function () {
expect('/random/path/whatever')->toBeWritableDirectory();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(sys_get_temp_dir())->not->toBeWritableDirectory();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,23 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
beforeEach(function () {
touch($this->tempFile = sys_get_temp_dir() . '/fake.file');
});
afterEach(function () {
unlink($this->tempFile);
});
test('pass', function () {
expect($this->tempFile)->toBeWritableFile();
});
test('failures', function () {
expect('/random/path/whatever.file')->toBeWritableFile();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect($this->tempFile)->not->toBeWritableFile();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,19 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('passes strings', function () {
expect([1, 2, 42])->toContain(42);
});
test('passes arrays', function () {
expect('Nuno')->toContain('Nu');
});
test('failures', function () {
expect([1, 2, 42])->toContain(3);
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect([1, 2, 42])->not->toContain(42);
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,15 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect('username')->toEndWith('name');
});
test('failures', function () {
expect('username')->toEndWith('password');
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect('username')->not->toEndWith('name');
})->throws(ExpectationFailedException::class);

15
tests/Expect/toEqual.php Normal file
View File

@ -0,0 +1,15 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect('00123')->toEqual(123);
});
test('failures', function () {
expect(['a', 'b', 'c'])->toEqual(['a', 'b']);
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect('042')->not->toEqual(42);
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,16 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect([1, 2, 3])->toEqualCanonicalizing([3, 1, 2]);
expect(['g', 'a', 'z'])->not->toEqualCanonicalizing(['a', 'z']);
});
test('failures', function () {
expect([3, 2, 1])->toEqualCanonicalizing([1, 2]);
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(['a', 'b', 'c'])->not->toEqualCanonicalizing(['b', 'a', 'c']);
})->throws(ExpectationFailedException::class);

Some files were not shown because too many files have changed in this diff Show More