├── .gitignore ├── README.md ├── composer.json ├── composer.lock ├── phpunit.xml.dist └── src ├── ConcreteDependencies ├── Invoice.php ├── InvoicePeriod.php ├── InvoiceService.php ├── InvoiceServiceTest.php └── UnableToInvoiceClient.php ├── DifficultToRenameWithMocks ├── DependingCode.php ├── DependingCodeTest.php └── ExternalDependency.php └── InterfacedDependencies ├── FakeInvoicePortal.php ├── FakeInvoicePortalTest.php ├── FlysystemInvoicePortal.php ├── FlysystemInvoicePortalTest.php ├── Invoice.php ├── InvoicePeriod.php ├── InvoicePortal.php ├── InvoicePortalTestCase.php ├── InvoiceService.php ├── InvoiceServiceTest.php └── UnableToInvoiceClient.php /.gitignore: -------------------------------------------------------------------------------- 1 | coverage 2 | vendor 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Testing without mocking frameworks. 2 | 3 | This repository contains example code to illustrate how to test without using 4 | a mocking framework. This code was written for the following blog post: 5 | 6 | > https://blog.frankdejonge.nl/testing-without-mocking-frameworks/ 7 | 8 | To run the code, run the following commands: 9 | 10 | ```bash 11 | git clone git@github.com:frankdejonge/testing-without-mocking-frameworks.git 12 | cd testing-without-mocking-frameworks 13 | composer install 14 | vendor/bin/phpunit 15 | ``` 16 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "frankdejonge/testing-without-mocking-frameworks", 3 | "type": "project", 4 | "autoload": { 5 | "psr-4": { 6 | "TestingWithoutMockingFrameworks\\": "src/" 7 | } 8 | }, 9 | "require-dev": { 10 | "mockery/mockery": "^1.3", 11 | "phpunit/phpunit": "^9.0" 12 | }, 13 | "license": "MIT", 14 | "authors": [ 15 | { 16 | "name": "Frank de Jonge", 17 | "email": "info@frenky.net" 18 | } 19 | ], 20 | "require": { 21 | "league/flysystem": "2.0.0-alpha.3", 22 | "league/flysystem-memory": "2.0.0-alpha.3", 23 | "ext-json": "*" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "5d1a68f26ae3897cf29460739c709499", 8 | "packages": [ 9 | { 10 | "name": "league/flysystem", 11 | "version": "2.0.0-alpha.3", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/thephpleague/flysystem.git", 15 | "reference": "0d8cdd573af8b6ad2baa60e4e9ba8a48b86e9bb6" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/0d8cdd573af8b6ad2baa60e4e9ba8a48b86e9bb6", 20 | "reference": "0d8cdd573af8b6ad2baa60e4e9ba8a48b86e9bb6", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "ext-json": "*", 25 | "league/mime-type-detection": "^1.0.0", 26 | "php": "^7.2" 27 | }, 28 | "conflict": { 29 | "guzzlehttp/ringphp": "<1.1.1" 30 | }, 31 | "require-dev": { 32 | "aws/aws-sdk-php": "^3.132.4", 33 | "phpseclib/phpseclib": "^2.0", 34 | "phpstan/phpstan": "^0.12.9", 35 | "phpunit/phpunit": "^8.5" 36 | }, 37 | "type": "library", 38 | "autoload": { 39 | "psr-4": { 40 | "League\\Flysystem\\": "src" 41 | } 42 | }, 43 | "notification-url": "https://packagist.org/downloads/", 44 | "license": [ 45 | "MIT" 46 | ], 47 | "authors": [ 48 | { 49 | "name": "Frank de Jonge", 50 | "email": "info@frankdejonge.nl" 51 | } 52 | ], 53 | "description": "File storage abstraction for PHP", 54 | "keywords": [ 55 | "WebDAV", 56 | "aws", 57 | "cloud", 58 | "file", 59 | "files", 60 | "filesystem", 61 | "filesystems", 62 | "ftp", 63 | "s3", 64 | "sftp", 65 | "storage" 66 | ], 67 | "time": "2020-03-21T15:57:57+00:00" 68 | }, 69 | { 70 | "name": "league/flysystem-memory", 71 | "version": "2.0.0-alpha.3", 72 | "source": { 73 | "type": "git", 74 | "url": "https://github.com/thephpleague/flysystem-memory.git", 75 | "reference": "6b9cbc91aad6e1523265c23d0c3a96664f44d1bd" 76 | }, 77 | "dist": { 78 | "type": "zip", 79 | "url": "https://api.github.com/repos/thephpleague/flysystem-memory/zipball/6b9cbc91aad6e1523265c23d0c3a96664f44d1bd", 80 | "reference": "6b9cbc91aad6e1523265c23d0c3a96664f44d1bd", 81 | "shasum": "" 82 | }, 83 | "require": { 84 | "league/flysystem": "2.0.0-alpha.3", 85 | "php": "^7.2" 86 | }, 87 | "type": "library", 88 | "autoload": { 89 | "psr-4": { 90 | "League\\Flysystem\\InMemory\\": "" 91 | } 92 | }, 93 | "notification-url": "https://packagist.org/downloads/", 94 | "license": [ 95 | "MIT" 96 | ], 97 | "authors": [ 98 | { 99 | "name": "Frank de Jonge", 100 | "email": "info@frankdejonge.nl" 101 | } 102 | ], 103 | "description": "In-memory filesystem adapter for Flysystem.", 104 | "keywords": [ 105 | "Flysystem", 106 | "file", 107 | "files", 108 | "filesystem", 109 | "memory" 110 | ], 111 | "time": "2020-03-21T15:56:55+00:00" 112 | }, 113 | { 114 | "name": "league/mime-type-detection", 115 | "version": "1.0.0", 116 | "source": { 117 | "type": "git", 118 | "url": "https://github.com/thephpleague/mime-type-detection.git", 119 | "reference": "bd4d425ab8eabcd8595571b33665ae3cd2aaeeff" 120 | }, 121 | "dist": { 122 | "type": "zip", 123 | "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/bd4d425ab8eabcd8595571b33665ae3cd2aaeeff", 124 | "reference": "bd4d425ab8eabcd8595571b33665ae3cd2aaeeff", 125 | "shasum": "" 126 | }, 127 | "require": { 128 | "ext-fileinfo": "*", 129 | "php": "^7.2" 130 | }, 131 | "require-dev": { 132 | "phpstan/phpstan": "^0.12.11", 133 | "phpunit/phpunit": "^8.5" 134 | }, 135 | "type": "library", 136 | "autoload": { 137 | "psr-4": { 138 | "League\\MimeTypeDetection\\": "src" 139 | } 140 | }, 141 | "notification-url": "https://packagist.org/downloads/", 142 | "license": [ 143 | "MIT" 144 | ], 145 | "authors": [ 146 | { 147 | "name": "Frank de Jonge", 148 | "email": "info@frankdejonge.nl" 149 | } 150 | ], 151 | "description": "Mime-type detection for Flysystem", 152 | "time": "2020-02-28T16:48:40+00:00" 153 | } 154 | ], 155 | "packages-dev": [ 156 | { 157 | "name": "doctrine/instantiator", 158 | "version": "1.3.0", 159 | "source": { 160 | "type": "git", 161 | "url": "https://github.com/doctrine/instantiator.git", 162 | "reference": "ae466f726242e637cebdd526a7d991b9433bacf1" 163 | }, 164 | "dist": { 165 | "type": "zip", 166 | "url": "https://api.github.com/repos/doctrine/instantiator/zipball/ae466f726242e637cebdd526a7d991b9433bacf1", 167 | "reference": "ae466f726242e637cebdd526a7d991b9433bacf1", 168 | "shasum": "" 169 | }, 170 | "require": { 171 | "php": "^7.1" 172 | }, 173 | "require-dev": { 174 | "doctrine/coding-standard": "^6.0", 175 | "ext-pdo": "*", 176 | "ext-phar": "*", 177 | "phpbench/phpbench": "^0.13", 178 | "phpstan/phpstan-phpunit": "^0.11", 179 | "phpstan/phpstan-shim": "^0.11", 180 | "phpunit/phpunit": "^7.0" 181 | }, 182 | "type": "library", 183 | "extra": { 184 | "branch-alias": { 185 | "dev-master": "1.2.x-dev" 186 | } 187 | }, 188 | "autoload": { 189 | "psr-4": { 190 | "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" 191 | } 192 | }, 193 | "notification-url": "https://packagist.org/downloads/", 194 | "license": [ 195 | "MIT" 196 | ], 197 | "authors": [ 198 | { 199 | "name": "Marco Pivetta", 200 | "email": "ocramius@gmail.com", 201 | "homepage": "http://ocramius.github.com/" 202 | } 203 | ], 204 | "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", 205 | "homepage": "https://www.doctrine-project.org/projects/instantiator.html", 206 | "keywords": [ 207 | "constructor", 208 | "instantiate" 209 | ], 210 | "time": "2019-10-21T16:45:58+00:00" 211 | }, 212 | { 213 | "name": "hamcrest/hamcrest-php", 214 | "version": "v2.0.0", 215 | "source": { 216 | "type": "git", 217 | "url": "https://github.com/hamcrest/hamcrest-php.git", 218 | "reference": "776503d3a8e85d4f9a1148614f95b7a608b046ad" 219 | }, 220 | "dist": { 221 | "type": "zip", 222 | "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/776503d3a8e85d4f9a1148614f95b7a608b046ad", 223 | "reference": "776503d3a8e85d4f9a1148614f95b7a608b046ad", 224 | "shasum": "" 225 | }, 226 | "require": { 227 | "php": "^5.3|^7.0" 228 | }, 229 | "replace": { 230 | "cordoval/hamcrest-php": "*", 231 | "davedevelopment/hamcrest-php": "*", 232 | "kodova/hamcrest-php": "*" 233 | }, 234 | "require-dev": { 235 | "phpunit/php-file-iterator": "1.3.3", 236 | "phpunit/phpunit": "~4.0", 237 | "satooshi/php-coveralls": "^1.0" 238 | }, 239 | "type": "library", 240 | "extra": { 241 | "branch-alias": { 242 | "dev-master": "2.0-dev" 243 | } 244 | }, 245 | "autoload": { 246 | "classmap": [ 247 | "hamcrest" 248 | ] 249 | }, 250 | "notification-url": "https://packagist.org/downloads/", 251 | "license": [ 252 | "BSD" 253 | ], 254 | "description": "This is the PHP port of Hamcrest Matchers", 255 | "keywords": [ 256 | "test" 257 | ], 258 | "time": "2016-01-20T08:20:44+00:00" 259 | }, 260 | { 261 | "name": "mockery/mockery", 262 | "version": "1.3.1", 263 | "source": { 264 | "type": "git", 265 | "url": "https://github.com/mockery/mockery.git", 266 | "reference": "f69bbde7d7a75d6b2862d9ca8fab1cd28014b4be" 267 | }, 268 | "dist": { 269 | "type": "zip", 270 | "url": "https://api.github.com/repos/mockery/mockery/zipball/f69bbde7d7a75d6b2862d9ca8fab1cd28014b4be", 271 | "reference": "f69bbde7d7a75d6b2862d9ca8fab1cd28014b4be", 272 | "shasum": "" 273 | }, 274 | "require": { 275 | "hamcrest/hamcrest-php": "~2.0", 276 | "lib-pcre": ">=7.0", 277 | "php": ">=5.6.0" 278 | }, 279 | "require-dev": { 280 | "phpunit/phpunit": "~5.7.10|~6.5|~7.0|~8.0" 281 | }, 282 | "type": "library", 283 | "extra": { 284 | "branch-alias": { 285 | "dev-master": "1.3.x-dev" 286 | } 287 | }, 288 | "autoload": { 289 | "psr-0": { 290 | "Mockery": "library/" 291 | } 292 | }, 293 | "notification-url": "https://packagist.org/downloads/", 294 | "license": [ 295 | "BSD-3-Clause" 296 | ], 297 | "authors": [ 298 | { 299 | "name": "Pádraic Brady", 300 | "email": "padraic.brady@gmail.com", 301 | "homepage": "http://blog.astrumfutura.com" 302 | }, 303 | { 304 | "name": "Dave Marshall", 305 | "email": "dave.marshall@atstsolutions.co.uk", 306 | "homepage": "http://davedevelopment.co.uk" 307 | } 308 | ], 309 | "description": "Mockery is a simple yet flexible PHP mock object framework", 310 | "homepage": "https://github.com/mockery/mockery", 311 | "keywords": [ 312 | "BDD", 313 | "TDD", 314 | "library", 315 | "mock", 316 | "mock objects", 317 | "mockery", 318 | "stub", 319 | "test", 320 | "test double", 321 | "testing" 322 | ], 323 | "time": "2019-12-26T09:49:15+00:00" 324 | }, 325 | { 326 | "name": "myclabs/deep-copy", 327 | "version": "1.9.5", 328 | "source": { 329 | "type": "git", 330 | "url": "https://github.com/myclabs/DeepCopy.git", 331 | "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef" 332 | }, 333 | "dist": { 334 | "type": "zip", 335 | "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/b2c28789e80a97badd14145fda39b545d83ca3ef", 336 | "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef", 337 | "shasum": "" 338 | }, 339 | "require": { 340 | "php": "^7.1" 341 | }, 342 | "replace": { 343 | "myclabs/deep-copy": "self.version" 344 | }, 345 | "require-dev": { 346 | "doctrine/collections": "^1.0", 347 | "doctrine/common": "^2.6", 348 | "phpunit/phpunit": "^7.1" 349 | }, 350 | "type": "library", 351 | "autoload": { 352 | "psr-4": { 353 | "DeepCopy\\": "src/DeepCopy/" 354 | }, 355 | "files": [ 356 | "src/DeepCopy/deep_copy.php" 357 | ] 358 | }, 359 | "notification-url": "https://packagist.org/downloads/", 360 | "license": [ 361 | "MIT" 362 | ], 363 | "description": "Create deep copies (clones) of your objects", 364 | "keywords": [ 365 | "clone", 366 | "copy", 367 | "duplicate", 368 | "object", 369 | "object graph" 370 | ], 371 | "time": "2020-01-17T21:11:47+00:00" 372 | }, 373 | { 374 | "name": "phar-io/manifest", 375 | "version": "1.0.3", 376 | "source": { 377 | "type": "git", 378 | "url": "https://github.com/phar-io/manifest.git", 379 | "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4" 380 | }, 381 | "dist": { 382 | "type": "zip", 383 | "url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", 384 | "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", 385 | "shasum": "" 386 | }, 387 | "require": { 388 | "ext-dom": "*", 389 | "ext-phar": "*", 390 | "phar-io/version": "^2.0", 391 | "php": "^5.6 || ^7.0" 392 | }, 393 | "type": "library", 394 | "extra": { 395 | "branch-alias": { 396 | "dev-master": "1.0.x-dev" 397 | } 398 | }, 399 | "autoload": { 400 | "classmap": [ 401 | "src/" 402 | ] 403 | }, 404 | "notification-url": "https://packagist.org/downloads/", 405 | "license": [ 406 | "BSD-3-Clause" 407 | ], 408 | "authors": [ 409 | { 410 | "name": "Arne Blankerts", 411 | "email": "arne@blankerts.de", 412 | "role": "Developer" 413 | }, 414 | { 415 | "name": "Sebastian Heuer", 416 | "email": "sebastian@phpeople.de", 417 | "role": "Developer" 418 | }, 419 | { 420 | "name": "Sebastian Bergmann", 421 | "email": "sebastian@phpunit.de", 422 | "role": "Developer" 423 | } 424 | ], 425 | "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", 426 | "time": "2018-07-08T19:23:20+00:00" 427 | }, 428 | { 429 | "name": "phar-io/version", 430 | "version": "2.0.1", 431 | "source": { 432 | "type": "git", 433 | "url": "https://github.com/phar-io/version.git", 434 | "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6" 435 | }, 436 | "dist": { 437 | "type": "zip", 438 | "url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6", 439 | "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6", 440 | "shasum": "" 441 | }, 442 | "require": { 443 | "php": "^5.6 || ^7.0" 444 | }, 445 | "type": "library", 446 | "autoload": { 447 | "classmap": [ 448 | "src/" 449 | ] 450 | }, 451 | "notification-url": "https://packagist.org/downloads/", 452 | "license": [ 453 | "BSD-3-Clause" 454 | ], 455 | "authors": [ 456 | { 457 | "name": "Arne Blankerts", 458 | "email": "arne@blankerts.de", 459 | "role": "Developer" 460 | }, 461 | { 462 | "name": "Sebastian Heuer", 463 | "email": "sebastian@phpeople.de", 464 | "role": "Developer" 465 | }, 466 | { 467 | "name": "Sebastian Bergmann", 468 | "email": "sebastian@phpunit.de", 469 | "role": "Developer" 470 | } 471 | ], 472 | "description": "Library for handling version information and constraints", 473 | "time": "2018-07-08T19:19:57+00:00" 474 | }, 475 | { 476 | "name": "phpdocumentor/reflection-common", 477 | "version": "2.0.0", 478 | "source": { 479 | "type": "git", 480 | "url": "https://github.com/phpDocumentor/ReflectionCommon.git", 481 | "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" 482 | }, 483 | "dist": { 484 | "type": "zip", 485 | "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", 486 | "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", 487 | "shasum": "" 488 | }, 489 | "require": { 490 | "php": ">=7.1" 491 | }, 492 | "require-dev": { 493 | "phpunit/phpunit": "~6" 494 | }, 495 | "type": "library", 496 | "extra": { 497 | "branch-alias": { 498 | "dev-master": "2.x-dev" 499 | } 500 | }, 501 | "autoload": { 502 | "psr-4": { 503 | "phpDocumentor\\Reflection\\": "src/" 504 | } 505 | }, 506 | "notification-url": "https://packagist.org/downloads/", 507 | "license": [ 508 | "MIT" 509 | ], 510 | "authors": [ 511 | { 512 | "name": "Jaap van Otterdijk", 513 | "email": "opensource@ijaap.nl" 514 | } 515 | ], 516 | "description": "Common reflection classes used by phpdocumentor to reflect the code structure", 517 | "homepage": "http://www.phpdoc.org", 518 | "keywords": [ 519 | "FQSEN", 520 | "phpDocumentor", 521 | "phpdoc", 522 | "reflection", 523 | "static analysis" 524 | ], 525 | "time": "2018-08-07T13:53:10+00:00" 526 | }, 527 | { 528 | "name": "phpdocumentor/reflection-docblock", 529 | "version": "5.1.0", 530 | "source": { 531 | "type": "git", 532 | "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", 533 | "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e" 534 | }, 535 | "dist": { 536 | "type": "zip", 537 | "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", 538 | "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", 539 | "shasum": "" 540 | }, 541 | "require": { 542 | "ext-filter": "^7.1", 543 | "php": "^7.2", 544 | "phpdocumentor/reflection-common": "^2.0", 545 | "phpdocumentor/type-resolver": "^1.0", 546 | "webmozart/assert": "^1" 547 | }, 548 | "require-dev": { 549 | "doctrine/instantiator": "^1", 550 | "mockery/mockery": "^1" 551 | }, 552 | "type": "library", 553 | "extra": { 554 | "branch-alias": { 555 | "dev-master": "5.x-dev" 556 | } 557 | }, 558 | "autoload": { 559 | "psr-4": { 560 | "phpDocumentor\\Reflection\\": "src" 561 | } 562 | }, 563 | "notification-url": "https://packagist.org/downloads/", 564 | "license": [ 565 | "MIT" 566 | ], 567 | "authors": [ 568 | { 569 | "name": "Mike van Riel", 570 | "email": "me@mikevanriel.com" 571 | }, 572 | { 573 | "name": "Jaap van Otterdijk", 574 | "email": "account@ijaap.nl" 575 | } 576 | ], 577 | "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", 578 | "time": "2020-02-22T12:28:44+00:00" 579 | }, 580 | { 581 | "name": "phpdocumentor/type-resolver", 582 | "version": "1.1.0", 583 | "source": { 584 | "type": "git", 585 | "url": "https://github.com/phpDocumentor/TypeResolver.git", 586 | "reference": "7462d5f123dfc080dfdf26897032a6513644fc95" 587 | }, 588 | "dist": { 589 | "type": "zip", 590 | "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/7462d5f123dfc080dfdf26897032a6513644fc95", 591 | "reference": "7462d5f123dfc080dfdf26897032a6513644fc95", 592 | "shasum": "" 593 | }, 594 | "require": { 595 | "php": "^7.2", 596 | "phpdocumentor/reflection-common": "^2.0" 597 | }, 598 | "require-dev": { 599 | "ext-tokenizer": "^7.2", 600 | "mockery/mockery": "~1" 601 | }, 602 | "type": "library", 603 | "extra": { 604 | "branch-alias": { 605 | "dev-master": "1.x-dev" 606 | } 607 | }, 608 | "autoload": { 609 | "psr-4": { 610 | "phpDocumentor\\Reflection\\": "src" 611 | } 612 | }, 613 | "notification-url": "https://packagist.org/downloads/", 614 | "license": [ 615 | "MIT" 616 | ], 617 | "authors": [ 618 | { 619 | "name": "Mike van Riel", 620 | "email": "me@mikevanriel.com" 621 | } 622 | ], 623 | "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", 624 | "time": "2020-02-18T18:59:58+00:00" 625 | }, 626 | { 627 | "name": "phpspec/prophecy", 628 | "version": "v1.10.3", 629 | "source": { 630 | "type": "git", 631 | "url": "https://github.com/phpspec/prophecy.git", 632 | "reference": "451c3cd1418cf640de218914901e51b064abb093" 633 | }, 634 | "dist": { 635 | "type": "zip", 636 | "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", 637 | "reference": "451c3cd1418cf640de218914901e51b064abb093", 638 | "shasum": "" 639 | }, 640 | "require": { 641 | "doctrine/instantiator": "^1.0.2", 642 | "php": "^5.3|^7.0", 643 | "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", 644 | "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", 645 | "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" 646 | }, 647 | "require-dev": { 648 | "phpspec/phpspec": "^2.5 || ^3.2", 649 | "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" 650 | }, 651 | "type": "library", 652 | "extra": { 653 | "branch-alias": { 654 | "dev-master": "1.10.x-dev" 655 | } 656 | }, 657 | "autoload": { 658 | "psr-4": { 659 | "Prophecy\\": "src/Prophecy" 660 | } 661 | }, 662 | "notification-url": "https://packagist.org/downloads/", 663 | "license": [ 664 | "MIT" 665 | ], 666 | "authors": [ 667 | { 668 | "name": "Konstantin Kudryashov", 669 | "email": "ever.zet@gmail.com", 670 | "homepage": "http://everzet.com" 671 | }, 672 | { 673 | "name": "Marcello Duarte", 674 | "email": "marcello.duarte@gmail.com" 675 | } 676 | ], 677 | "description": "Highly opinionated mocking framework for PHP 5.3+", 678 | "homepage": "https://github.com/phpspec/prophecy", 679 | "keywords": [ 680 | "Double", 681 | "Dummy", 682 | "fake", 683 | "mock", 684 | "spy", 685 | "stub" 686 | ], 687 | "time": "2020-03-05T15:02:03+00:00" 688 | }, 689 | { 690 | "name": "phpunit/php-code-coverage", 691 | "version": "8.0.1", 692 | "source": { 693 | "type": "git", 694 | "url": "https://github.com/sebastianbergmann/php-code-coverage.git", 695 | "reference": "31e94ccc084025d6abee0585df533eb3a792b96a" 696 | }, 697 | "dist": { 698 | "type": "zip", 699 | "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/31e94ccc084025d6abee0585df533eb3a792b96a", 700 | "reference": "31e94ccc084025d6abee0585df533eb3a792b96a", 701 | "shasum": "" 702 | }, 703 | "require": { 704 | "ext-dom": "*", 705 | "ext-xmlwriter": "*", 706 | "php": "^7.3", 707 | "phpunit/php-file-iterator": "^3.0", 708 | "phpunit/php-text-template": "^2.0", 709 | "phpunit/php-token-stream": "^4.0", 710 | "sebastian/code-unit-reverse-lookup": "^2.0", 711 | "sebastian/environment": "^5.0", 712 | "sebastian/version": "^3.0", 713 | "theseer/tokenizer": "^1.1.3" 714 | }, 715 | "require-dev": { 716 | "phpunit/phpunit": "^9.0" 717 | }, 718 | "suggest": { 719 | "ext-pcov": "*", 720 | "ext-xdebug": "*" 721 | }, 722 | "type": "library", 723 | "extra": { 724 | "branch-alias": { 725 | "dev-master": "8.0-dev" 726 | } 727 | }, 728 | "autoload": { 729 | "classmap": [ 730 | "src/" 731 | ] 732 | }, 733 | "notification-url": "https://packagist.org/downloads/", 734 | "license": [ 735 | "BSD-3-Clause" 736 | ], 737 | "authors": [ 738 | { 739 | "name": "Sebastian Bergmann", 740 | "email": "sebastian@phpunit.de", 741 | "role": "lead" 742 | } 743 | ], 744 | "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", 745 | "homepage": "https://github.com/sebastianbergmann/php-code-coverage", 746 | "keywords": [ 747 | "coverage", 748 | "testing", 749 | "xunit" 750 | ], 751 | "time": "2020-02-19T13:41:19+00:00" 752 | }, 753 | { 754 | "name": "phpunit/php-file-iterator", 755 | "version": "3.0.0", 756 | "source": { 757 | "type": "git", 758 | "url": "https://github.com/sebastianbergmann/php-file-iterator.git", 759 | "reference": "354d4a5faa7449a377a18b94a2026ca3415e3d7a" 760 | }, 761 | "dist": { 762 | "type": "zip", 763 | "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/354d4a5faa7449a377a18b94a2026ca3415e3d7a", 764 | "reference": "354d4a5faa7449a377a18b94a2026ca3415e3d7a", 765 | "shasum": "" 766 | }, 767 | "require": { 768 | "php": "^7.3" 769 | }, 770 | "require-dev": { 771 | "phpunit/phpunit": "^9.0" 772 | }, 773 | "type": "library", 774 | "extra": { 775 | "branch-alias": { 776 | "dev-master": "3.0-dev" 777 | } 778 | }, 779 | "autoload": { 780 | "classmap": [ 781 | "src/" 782 | ] 783 | }, 784 | "notification-url": "https://packagist.org/downloads/", 785 | "license": [ 786 | "BSD-3-Clause" 787 | ], 788 | "authors": [ 789 | { 790 | "name": "Sebastian Bergmann", 791 | "email": "sebastian@phpunit.de", 792 | "role": "lead" 793 | } 794 | ], 795 | "description": "FilterIterator implementation that filters files based on a list of suffixes.", 796 | "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", 797 | "keywords": [ 798 | "filesystem", 799 | "iterator" 800 | ], 801 | "time": "2020-02-07T06:05:22+00:00" 802 | }, 803 | { 804 | "name": "phpunit/php-invoker", 805 | "version": "3.0.0", 806 | "source": { 807 | "type": "git", 808 | "url": "https://github.com/sebastianbergmann/php-invoker.git", 809 | "reference": "7579d5a1ba7f3ac11c80004d205877911315ae7a" 810 | }, 811 | "dist": { 812 | "type": "zip", 813 | "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/7579d5a1ba7f3ac11c80004d205877911315ae7a", 814 | "reference": "7579d5a1ba7f3ac11c80004d205877911315ae7a", 815 | "shasum": "" 816 | }, 817 | "require": { 818 | "php": "^7.3" 819 | }, 820 | "require-dev": { 821 | "ext-pcntl": "*", 822 | "phpunit/phpunit": "^9.0" 823 | }, 824 | "suggest": { 825 | "ext-pcntl": "*" 826 | }, 827 | "type": "library", 828 | "extra": { 829 | "branch-alias": { 830 | "dev-master": "3.0-dev" 831 | } 832 | }, 833 | "autoload": { 834 | "classmap": [ 835 | "src/" 836 | ] 837 | }, 838 | "notification-url": "https://packagist.org/downloads/", 839 | "license": [ 840 | "BSD-3-Clause" 841 | ], 842 | "authors": [ 843 | { 844 | "name": "Sebastian Bergmann", 845 | "email": "sebastian@phpunit.de", 846 | "role": "lead" 847 | } 848 | ], 849 | "description": "Invoke callables with a timeout", 850 | "homepage": "https://github.com/sebastianbergmann/php-invoker/", 851 | "keywords": [ 852 | "process" 853 | ], 854 | "time": "2020-02-07T06:06:11+00:00" 855 | }, 856 | { 857 | "name": "phpunit/php-text-template", 858 | "version": "2.0.0", 859 | "source": { 860 | "type": "git", 861 | "url": "https://github.com/sebastianbergmann/php-text-template.git", 862 | "reference": "526dc996cc0ebdfa428cd2dfccd79b7b53fee346" 863 | }, 864 | "dist": { 865 | "type": "zip", 866 | "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/526dc996cc0ebdfa428cd2dfccd79b7b53fee346", 867 | "reference": "526dc996cc0ebdfa428cd2dfccd79b7b53fee346", 868 | "shasum": "" 869 | }, 870 | "require": { 871 | "php": "^7.3" 872 | }, 873 | "type": "library", 874 | "extra": { 875 | "branch-alias": { 876 | "dev-master": "2.0-dev" 877 | } 878 | }, 879 | "autoload": { 880 | "classmap": [ 881 | "src/" 882 | ] 883 | }, 884 | "notification-url": "https://packagist.org/downloads/", 885 | "license": [ 886 | "BSD-3-Clause" 887 | ], 888 | "authors": [ 889 | { 890 | "name": "Sebastian Bergmann", 891 | "email": "sebastian@phpunit.de", 892 | "role": "lead" 893 | } 894 | ], 895 | "description": "Simple template engine.", 896 | "homepage": "https://github.com/sebastianbergmann/php-text-template/", 897 | "keywords": [ 898 | "template" 899 | ], 900 | "time": "2020-02-01T07:43:44+00:00" 901 | }, 902 | { 903 | "name": "phpunit/php-timer", 904 | "version": "3.0.0", 905 | "source": { 906 | "type": "git", 907 | "url": "https://github.com/sebastianbergmann/php-timer.git", 908 | "reference": "4118013a4d0f97356eae8e7fb2f6c6472575d1df" 909 | }, 910 | "dist": { 911 | "type": "zip", 912 | "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/4118013a4d0f97356eae8e7fb2f6c6472575d1df", 913 | "reference": "4118013a4d0f97356eae8e7fb2f6c6472575d1df", 914 | "shasum": "" 915 | }, 916 | "require": { 917 | "php": "^7.3" 918 | }, 919 | "require-dev": { 920 | "phpunit/phpunit": "^9.0" 921 | }, 922 | "type": "library", 923 | "extra": { 924 | "branch-alias": { 925 | "dev-master": "3.0-dev" 926 | } 927 | }, 928 | "autoload": { 929 | "classmap": [ 930 | "src/" 931 | ] 932 | }, 933 | "notification-url": "https://packagist.org/downloads/", 934 | "license": [ 935 | "BSD-3-Clause" 936 | ], 937 | "authors": [ 938 | { 939 | "name": "Sebastian Bergmann", 940 | "email": "sebastian@phpunit.de", 941 | "role": "lead" 942 | } 943 | ], 944 | "description": "Utility class for timing", 945 | "homepage": "https://github.com/sebastianbergmann/php-timer/", 946 | "keywords": [ 947 | "timer" 948 | ], 949 | "time": "2020-02-07T06:08:11+00:00" 950 | }, 951 | { 952 | "name": "phpunit/php-token-stream", 953 | "version": "4.0.0", 954 | "source": { 955 | "type": "git", 956 | "url": "https://github.com/sebastianbergmann/php-token-stream.git", 957 | "reference": "b2560a0c33f7710e4d7f8780964193e8e8f8effe" 958 | }, 959 | "dist": { 960 | "type": "zip", 961 | "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/b2560a0c33f7710e4d7f8780964193e8e8f8effe", 962 | "reference": "b2560a0c33f7710e4d7f8780964193e8e8f8effe", 963 | "shasum": "" 964 | }, 965 | "require": { 966 | "ext-tokenizer": "*", 967 | "php": "^7.3" 968 | }, 969 | "require-dev": { 970 | "phpunit/phpunit": "^9.0" 971 | }, 972 | "type": "library", 973 | "extra": { 974 | "branch-alias": { 975 | "dev-master": "4.0-dev" 976 | } 977 | }, 978 | "autoload": { 979 | "classmap": [ 980 | "src/" 981 | ] 982 | }, 983 | "notification-url": "https://packagist.org/downloads/", 984 | "license": [ 985 | "BSD-3-Clause" 986 | ], 987 | "authors": [ 988 | { 989 | "name": "Sebastian Bergmann", 990 | "email": "sebastian@phpunit.de" 991 | } 992 | ], 993 | "description": "Wrapper around PHP's tokenizer extension.", 994 | "homepage": "https://github.com/sebastianbergmann/php-token-stream/", 995 | "keywords": [ 996 | "tokenizer" 997 | ], 998 | "time": "2020-02-07T06:19:00+00:00" 999 | }, 1000 | { 1001 | "name": "phpunit/phpunit", 1002 | "version": "9.0.1", 1003 | "source": { 1004 | "type": "git", 1005 | "url": "https://github.com/sebastianbergmann/phpunit.git", 1006 | "reference": "68d7e5b17a6b9461e17c00446caa409863154f76" 1007 | }, 1008 | "dist": { 1009 | "type": "zip", 1010 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/68d7e5b17a6b9461e17c00446caa409863154f76", 1011 | "reference": "68d7e5b17a6b9461e17c00446caa409863154f76", 1012 | "shasum": "" 1013 | }, 1014 | "require": { 1015 | "doctrine/instantiator": "^1.2.0", 1016 | "ext-dom": "*", 1017 | "ext-json": "*", 1018 | "ext-libxml": "*", 1019 | "ext-mbstring": "*", 1020 | "ext-xml": "*", 1021 | "ext-xmlwriter": "*", 1022 | "myclabs/deep-copy": "^1.9.1", 1023 | "phar-io/manifest": "^1.0.3", 1024 | "phar-io/version": "^2.0.1", 1025 | "php": "^7.3", 1026 | "phpspec/prophecy": "^1.8.1", 1027 | "phpunit/php-code-coverage": "^8.0", 1028 | "phpunit/php-file-iterator": "^3.0", 1029 | "phpunit/php-invoker": "^3.0", 1030 | "phpunit/php-text-template": "^2.0", 1031 | "phpunit/php-timer": "^3.0", 1032 | "sebastian/comparator": "^4.0", 1033 | "sebastian/diff": "^4.0", 1034 | "sebastian/environment": "^5.0", 1035 | "sebastian/exporter": "^4.0", 1036 | "sebastian/global-state": "^4.0", 1037 | "sebastian/object-enumerator": "^4.0", 1038 | "sebastian/resource-operations": "^3.0", 1039 | "sebastian/type": "^2.0", 1040 | "sebastian/version": "^3.0" 1041 | }, 1042 | "require-dev": { 1043 | "ext-pdo": "*" 1044 | }, 1045 | "suggest": { 1046 | "ext-soap": "*", 1047 | "ext-xdebug": "*" 1048 | }, 1049 | "bin": [ 1050 | "phpunit" 1051 | ], 1052 | "type": "library", 1053 | "extra": { 1054 | "branch-alias": { 1055 | "dev-master": "9.0-dev" 1056 | } 1057 | }, 1058 | "autoload": { 1059 | "classmap": [ 1060 | "src/" 1061 | ], 1062 | "files": [ 1063 | "src/Framework/Assert/Functions.php" 1064 | ] 1065 | }, 1066 | "notification-url": "https://packagist.org/downloads/", 1067 | "license": [ 1068 | "BSD-3-Clause" 1069 | ], 1070 | "authors": [ 1071 | { 1072 | "name": "Sebastian Bergmann", 1073 | "email": "sebastian@phpunit.de", 1074 | "role": "lead" 1075 | } 1076 | ], 1077 | "description": "The PHP Unit Testing framework.", 1078 | "homepage": "https://phpunit.de/", 1079 | "keywords": [ 1080 | "phpunit", 1081 | "testing", 1082 | "xunit" 1083 | ], 1084 | "time": "2020-02-13T07:30:12+00:00" 1085 | }, 1086 | { 1087 | "name": "sebastian/code-unit-reverse-lookup", 1088 | "version": "2.0.0", 1089 | "source": { 1090 | "type": "git", 1091 | "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", 1092 | "reference": "5b5dbe0044085ac41df47e79d34911a15b96d82e" 1093 | }, 1094 | "dist": { 1095 | "type": "zip", 1096 | "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/5b5dbe0044085ac41df47e79d34911a15b96d82e", 1097 | "reference": "5b5dbe0044085ac41df47e79d34911a15b96d82e", 1098 | "shasum": "" 1099 | }, 1100 | "require": { 1101 | "php": "^7.3" 1102 | }, 1103 | "require-dev": { 1104 | "phpunit/phpunit": "^9.0" 1105 | }, 1106 | "type": "library", 1107 | "extra": { 1108 | "branch-alias": { 1109 | "dev-master": "2.0-dev" 1110 | } 1111 | }, 1112 | "autoload": { 1113 | "classmap": [ 1114 | "src/" 1115 | ] 1116 | }, 1117 | "notification-url": "https://packagist.org/downloads/", 1118 | "license": [ 1119 | "BSD-3-Clause" 1120 | ], 1121 | "authors": [ 1122 | { 1123 | "name": "Sebastian Bergmann", 1124 | "email": "sebastian@phpunit.de" 1125 | } 1126 | ], 1127 | "description": "Looks up which function or method a line of code belongs to", 1128 | "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", 1129 | "time": "2020-02-07T06:20:13+00:00" 1130 | }, 1131 | { 1132 | "name": "sebastian/comparator", 1133 | "version": "4.0.0", 1134 | "source": { 1135 | "type": "git", 1136 | "url": "https://github.com/sebastianbergmann/comparator.git", 1137 | "reference": "85b3435da967696ed618ff745f32be3ff4a2b8e8" 1138 | }, 1139 | "dist": { 1140 | "type": "zip", 1141 | "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/85b3435da967696ed618ff745f32be3ff4a2b8e8", 1142 | "reference": "85b3435da967696ed618ff745f32be3ff4a2b8e8", 1143 | "shasum": "" 1144 | }, 1145 | "require": { 1146 | "php": "^7.3", 1147 | "sebastian/diff": "^4.0", 1148 | "sebastian/exporter": "^4.0" 1149 | }, 1150 | "require-dev": { 1151 | "phpunit/phpunit": "^9.0" 1152 | }, 1153 | "type": "library", 1154 | "extra": { 1155 | "branch-alias": { 1156 | "dev-master": "4.0-dev" 1157 | } 1158 | }, 1159 | "autoload": { 1160 | "classmap": [ 1161 | "src/" 1162 | ] 1163 | }, 1164 | "notification-url": "https://packagist.org/downloads/", 1165 | "license": [ 1166 | "BSD-3-Clause" 1167 | ], 1168 | "authors": [ 1169 | { 1170 | "name": "Sebastian Bergmann", 1171 | "email": "sebastian@phpunit.de" 1172 | }, 1173 | { 1174 | "name": "Jeff Welch", 1175 | "email": "whatthejeff@gmail.com" 1176 | }, 1177 | { 1178 | "name": "Volker Dusch", 1179 | "email": "github@wallbash.com" 1180 | }, 1181 | { 1182 | "name": "Bernhard Schussek", 1183 | "email": "bschussek@2bepublished.at" 1184 | } 1185 | ], 1186 | "description": "Provides the functionality to compare PHP values for equality", 1187 | "homepage": "https://github.com/sebastianbergmann/comparator", 1188 | "keywords": [ 1189 | "comparator", 1190 | "compare", 1191 | "equality" 1192 | ], 1193 | "time": "2020-02-07T06:08:51+00:00" 1194 | }, 1195 | { 1196 | "name": "sebastian/diff", 1197 | "version": "4.0.0", 1198 | "source": { 1199 | "type": "git", 1200 | "url": "https://github.com/sebastianbergmann/diff.git", 1201 | "reference": "c0c26c9188b538bfa985ae10c9f05d278f12060d" 1202 | }, 1203 | "dist": { 1204 | "type": "zip", 1205 | "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/c0c26c9188b538bfa985ae10c9f05d278f12060d", 1206 | "reference": "c0c26c9188b538bfa985ae10c9f05d278f12060d", 1207 | "shasum": "" 1208 | }, 1209 | "require": { 1210 | "php": "^7.3" 1211 | }, 1212 | "require-dev": { 1213 | "phpunit/phpunit": "^9.0", 1214 | "symfony/process": "^4 || ^5" 1215 | }, 1216 | "type": "library", 1217 | "extra": { 1218 | "branch-alias": { 1219 | "dev-master": "4.0-dev" 1220 | } 1221 | }, 1222 | "autoload": { 1223 | "classmap": [ 1224 | "src/" 1225 | ] 1226 | }, 1227 | "notification-url": "https://packagist.org/downloads/", 1228 | "license": [ 1229 | "BSD-3-Clause" 1230 | ], 1231 | "authors": [ 1232 | { 1233 | "name": "Sebastian Bergmann", 1234 | "email": "sebastian@phpunit.de" 1235 | }, 1236 | { 1237 | "name": "Kore Nordmann", 1238 | "email": "mail@kore-nordmann.de" 1239 | } 1240 | ], 1241 | "description": "Diff implementation", 1242 | "homepage": "https://github.com/sebastianbergmann/diff", 1243 | "keywords": [ 1244 | "diff", 1245 | "udiff", 1246 | "unidiff", 1247 | "unified diff" 1248 | ], 1249 | "time": "2020-02-07T06:09:38+00:00" 1250 | }, 1251 | { 1252 | "name": "sebastian/environment", 1253 | "version": "5.0.1", 1254 | "source": { 1255 | "type": "git", 1256 | "url": "https://github.com/sebastianbergmann/environment.git", 1257 | "reference": "9bffdefa7810031a165ddd6275da6a2c1f6f2dfb" 1258 | }, 1259 | "dist": { 1260 | "type": "zip", 1261 | "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/9bffdefa7810031a165ddd6275da6a2c1f6f2dfb", 1262 | "reference": "9bffdefa7810031a165ddd6275da6a2c1f6f2dfb", 1263 | "shasum": "" 1264 | }, 1265 | "require": { 1266 | "php": "^7.3" 1267 | }, 1268 | "require-dev": { 1269 | "phpunit/phpunit": "^9.0" 1270 | }, 1271 | "suggest": { 1272 | "ext-posix": "*" 1273 | }, 1274 | "type": "library", 1275 | "extra": { 1276 | "branch-alias": { 1277 | "dev-master": "5.0-dev" 1278 | } 1279 | }, 1280 | "autoload": { 1281 | "classmap": [ 1282 | "src/" 1283 | ] 1284 | }, 1285 | "notification-url": "https://packagist.org/downloads/", 1286 | "license": [ 1287 | "BSD-3-Clause" 1288 | ], 1289 | "authors": [ 1290 | { 1291 | "name": "Sebastian Bergmann", 1292 | "email": "sebastian@phpunit.de" 1293 | } 1294 | ], 1295 | "description": "Provides functionality to handle HHVM/PHP environments", 1296 | "homepage": "http://www.github.com/sebastianbergmann/environment", 1297 | "keywords": [ 1298 | "Xdebug", 1299 | "environment", 1300 | "hhvm" 1301 | ], 1302 | "time": "2020-02-19T13:40:20+00:00" 1303 | }, 1304 | { 1305 | "name": "sebastian/exporter", 1306 | "version": "4.0.0", 1307 | "source": { 1308 | "type": "git", 1309 | "url": "https://github.com/sebastianbergmann/exporter.git", 1310 | "reference": "80c26562e964016538f832f305b2286e1ec29566" 1311 | }, 1312 | "dist": { 1313 | "type": "zip", 1314 | "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/80c26562e964016538f832f305b2286e1ec29566", 1315 | "reference": "80c26562e964016538f832f305b2286e1ec29566", 1316 | "shasum": "" 1317 | }, 1318 | "require": { 1319 | "php": "^7.3", 1320 | "sebastian/recursion-context": "^4.0" 1321 | }, 1322 | "require-dev": { 1323 | "ext-mbstring": "*", 1324 | "phpunit/phpunit": "^9.0" 1325 | }, 1326 | "type": "library", 1327 | "extra": { 1328 | "branch-alias": { 1329 | "dev-master": "4.0-dev" 1330 | } 1331 | }, 1332 | "autoload": { 1333 | "classmap": [ 1334 | "src/" 1335 | ] 1336 | }, 1337 | "notification-url": "https://packagist.org/downloads/", 1338 | "license": [ 1339 | "BSD-3-Clause" 1340 | ], 1341 | "authors": [ 1342 | { 1343 | "name": "Sebastian Bergmann", 1344 | "email": "sebastian@phpunit.de" 1345 | }, 1346 | { 1347 | "name": "Jeff Welch", 1348 | "email": "whatthejeff@gmail.com" 1349 | }, 1350 | { 1351 | "name": "Volker Dusch", 1352 | "email": "github@wallbash.com" 1353 | }, 1354 | { 1355 | "name": "Adam Harvey", 1356 | "email": "aharvey@php.net" 1357 | }, 1358 | { 1359 | "name": "Bernhard Schussek", 1360 | "email": "bschussek@gmail.com" 1361 | } 1362 | ], 1363 | "description": "Provides the functionality to export PHP variables for visualization", 1364 | "homepage": "http://www.github.com/sebastianbergmann/exporter", 1365 | "keywords": [ 1366 | "export", 1367 | "exporter" 1368 | ], 1369 | "time": "2020-02-07T06:10:52+00:00" 1370 | }, 1371 | { 1372 | "name": "sebastian/global-state", 1373 | "version": "4.0.0", 1374 | "source": { 1375 | "type": "git", 1376 | "url": "https://github.com/sebastianbergmann/global-state.git", 1377 | "reference": "bdb1e7c79e592b8c82cb1699be3c8743119b8a72" 1378 | }, 1379 | "dist": { 1380 | "type": "zip", 1381 | "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bdb1e7c79e592b8c82cb1699be3c8743119b8a72", 1382 | "reference": "bdb1e7c79e592b8c82cb1699be3c8743119b8a72", 1383 | "shasum": "" 1384 | }, 1385 | "require": { 1386 | "php": "^7.3", 1387 | "sebastian/object-reflector": "^2.0", 1388 | "sebastian/recursion-context": "^4.0" 1389 | }, 1390 | "require-dev": { 1391 | "ext-dom": "*", 1392 | "phpunit/phpunit": "^9.0" 1393 | }, 1394 | "suggest": { 1395 | "ext-uopz": "*" 1396 | }, 1397 | "type": "library", 1398 | "extra": { 1399 | "branch-alias": { 1400 | "dev-master": "4.0-dev" 1401 | } 1402 | }, 1403 | "autoload": { 1404 | "classmap": [ 1405 | "src/" 1406 | ] 1407 | }, 1408 | "notification-url": "https://packagist.org/downloads/", 1409 | "license": [ 1410 | "BSD-3-Clause" 1411 | ], 1412 | "authors": [ 1413 | { 1414 | "name": "Sebastian Bergmann", 1415 | "email": "sebastian@phpunit.de" 1416 | } 1417 | ], 1418 | "description": "Snapshotting of global state", 1419 | "homepage": "http://www.github.com/sebastianbergmann/global-state", 1420 | "keywords": [ 1421 | "global state" 1422 | ], 1423 | "time": "2020-02-07T06:11:37+00:00" 1424 | }, 1425 | { 1426 | "name": "sebastian/object-enumerator", 1427 | "version": "4.0.0", 1428 | "source": { 1429 | "type": "git", 1430 | "url": "https://github.com/sebastianbergmann/object-enumerator.git", 1431 | "reference": "e67516b175550abad905dc952f43285957ef4363" 1432 | }, 1433 | "dist": { 1434 | "type": "zip", 1435 | "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/e67516b175550abad905dc952f43285957ef4363", 1436 | "reference": "e67516b175550abad905dc952f43285957ef4363", 1437 | "shasum": "" 1438 | }, 1439 | "require": { 1440 | "php": "^7.3", 1441 | "sebastian/object-reflector": "^2.0", 1442 | "sebastian/recursion-context": "^4.0" 1443 | }, 1444 | "require-dev": { 1445 | "phpunit/phpunit": "^9.0" 1446 | }, 1447 | "type": "library", 1448 | "extra": { 1449 | "branch-alias": { 1450 | "dev-master": "4.0-dev" 1451 | } 1452 | }, 1453 | "autoload": { 1454 | "classmap": [ 1455 | "src/" 1456 | ] 1457 | }, 1458 | "notification-url": "https://packagist.org/downloads/", 1459 | "license": [ 1460 | "BSD-3-Clause" 1461 | ], 1462 | "authors": [ 1463 | { 1464 | "name": "Sebastian Bergmann", 1465 | "email": "sebastian@phpunit.de" 1466 | } 1467 | ], 1468 | "description": "Traverses array structures and object graphs to enumerate all referenced objects", 1469 | "homepage": "https://github.com/sebastianbergmann/object-enumerator/", 1470 | "time": "2020-02-07T06:12:23+00:00" 1471 | }, 1472 | { 1473 | "name": "sebastian/object-reflector", 1474 | "version": "2.0.0", 1475 | "source": { 1476 | "type": "git", 1477 | "url": "https://github.com/sebastianbergmann/object-reflector.git", 1478 | "reference": "f4fd0835cabb0d4a6546d9fe291e5740037aa1e7" 1479 | }, 1480 | "dist": { 1481 | "type": "zip", 1482 | "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/f4fd0835cabb0d4a6546d9fe291e5740037aa1e7", 1483 | "reference": "f4fd0835cabb0d4a6546d9fe291e5740037aa1e7", 1484 | "shasum": "" 1485 | }, 1486 | "require": { 1487 | "php": "^7.3" 1488 | }, 1489 | "require-dev": { 1490 | "phpunit/phpunit": "^9.0" 1491 | }, 1492 | "type": "library", 1493 | "extra": { 1494 | "branch-alias": { 1495 | "dev-master": "2.0-dev" 1496 | } 1497 | }, 1498 | "autoload": { 1499 | "classmap": [ 1500 | "src/" 1501 | ] 1502 | }, 1503 | "notification-url": "https://packagist.org/downloads/", 1504 | "license": [ 1505 | "BSD-3-Clause" 1506 | ], 1507 | "authors": [ 1508 | { 1509 | "name": "Sebastian Bergmann", 1510 | "email": "sebastian@phpunit.de" 1511 | } 1512 | ], 1513 | "description": "Allows reflection of object attributes, including inherited and non-public ones", 1514 | "homepage": "https://github.com/sebastianbergmann/object-reflector/", 1515 | "time": "2020-02-07T06:19:40+00:00" 1516 | }, 1517 | { 1518 | "name": "sebastian/recursion-context", 1519 | "version": "4.0.0", 1520 | "source": { 1521 | "type": "git", 1522 | "url": "https://github.com/sebastianbergmann/recursion-context.git", 1523 | "reference": "cdd86616411fc3062368b720b0425de10bd3d579" 1524 | }, 1525 | "dist": { 1526 | "type": "zip", 1527 | "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cdd86616411fc3062368b720b0425de10bd3d579", 1528 | "reference": "cdd86616411fc3062368b720b0425de10bd3d579", 1529 | "shasum": "" 1530 | }, 1531 | "require": { 1532 | "php": "^7.3" 1533 | }, 1534 | "require-dev": { 1535 | "phpunit/phpunit": "^9.0" 1536 | }, 1537 | "type": "library", 1538 | "extra": { 1539 | "branch-alias": { 1540 | "dev-master": "4.0-dev" 1541 | } 1542 | }, 1543 | "autoload": { 1544 | "classmap": [ 1545 | "src/" 1546 | ] 1547 | }, 1548 | "notification-url": "https://packagist.org/downloads/", 1549 | "license": [ 1550 | "BSD-3-Clause" 1551 | ], 1552 | "authors": [ 1553 | { 1554 | "name": "Sebastian Bergmann", 1555 | "email": "sebastian@phpunit.de" 1556 | }, 1557 | { 1558 | "name": "Jeff Welch", 1559 | "email": "whatthejeff@gmail.com" 1560 | }, 1561 | { 1562 | "name": "Adam Harvey", 1563 | "email": "aharvey@php.net" 1564 | } 1565 | ], 1566 | "description": "Provides functionality to recursively process PHP variables", 1567 | "homepage": "http://www.github.com/sebastianbergmann/recursion-context", 1568 | "time": "2020-02-07T06:18:20+00:00" 1569 | }, 1570 | { 1571 | "name": "sebastian/resource-operations", 1572 | "version": "3.0.0", 1573 | "source": { 1574 | "type": "git", 1575 | "url": "https://github.com/sebastianbergmann/resource-operations.git", 1576 | "reference": "8c98bf0dfa1f9256d0468b9803a1e1df31b6fa98" 1577 | }, 1578 | "dist": { 1579 | "type": "zip", 1580 | "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/8c98bf0dfa1f9256d0468b9803a1e1df31b6fa98", 1581 | "reference": "8c98bf0dfa1f9256d0468b9803a1e1df31b6fa98", 1582 | "shasum": "" 1583 | }, 1584 | "require": { 1585 | "php": "^7.3" 1586 | }, 1587 | "require-dev": { 1588 | "phpunit/phpunit": "^9.0" 1589 | }, 1590 | "type": "library", 1591 | "extra": { 1592 | "branch-alias": { 1593 | "dev-master": "3.0-dev" 1594 | } 1595 | }, 1596 | "autoload": { 1597 | "classmap": [ 1598 | "src/" 1599 | ] 1600 | }, 1601 | "notification-url": "https://packagist.org/downloads/", 1602 | "license": [ 1603 | "BSD-3-Clause" 1604 | ], 1605 | "authors": [ 1606 | { 1607 | "name": "Sebastian Bergmann", 1608 | "email": "sebastian@phpunit.de" 1609 | } 1610 | ], 1611 | "description": "Provides a list of PHP built-in functions that operate on resources", 1612 | "homepage": "https://www.github.com/sebastianbergmann/resource-operations", 1613 | "time": "2020-02-07T06:13:02+00:00" 1614 | }, 1615 | { 1616 | "name": "sebastian/type", 1617 | "version": "2.0.0", 1618 | "source": { 1619 | "type": "git", 1620 | "url": "https://github.com/sebastianbergmann/type.git", 1621 | "reference": "9e8f42f740afdea51f5f4e8cec2035580e797ee1" 1622 | }, 1623 | "dist": { 1624 | "type": "zip", 1625 | "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/9e8f42f740afdea51f5f4e8cec2035580e797ee1", 1626 | "reference": "9e8f42f740afdea51f5f4e8cec2035580e797ee1", 1627 | "shasum": "" 1628 | }, 1629 | "require": { 1630 | "php": "^7.3" 1631 | }, 1632 | "require-dev": { 1633 | "phpunit/phpunit": "^9.0" 1634 | }, 1635 | "type": "library", 1636 | "extra": { 1637 | "branch-alias": { 1638 | "dev-master": "2.0-dev" 1639 | } 1640 | }, 1641 | "autoload": { 1642 | "classmap": [ 1643 | "src/" 1644 | ] 1645 | }, 1646 | "notification-url": "https://packagist.org/downloads/", 1647 | "license": [ 1648 | "BSD-3-Clause" 1649 | ], 1650 | "authors": [ 1651 | { 1652 | "name": "Sebastian Bergmann", 1653 | "email": "sebastian@phpunit.de", 1654 | "role": "lead" 1655 | } 1656 | ], 1657 | "description": "Collection of value objects that represent the types of the PHP type system", 1658 | "homepage": "https://github.com/sebastianbergmann/type", 1659 | "time": "2020-02-07T06:13:43+00:00" 1660 | }, 1661 | { 1662 | "name": "sebastian/version", 1663 | "version": "3.0.0", 1664 | "source": { 1665 | "type": "git", 1666 | "url": "https://github.com/sebastianbergmann/version.git", 1667 | "reference": "0411bde656dce64202b39c2f4473993a9081d39e" 1668 | }, 1669 | "dist": { 1670 | "type": "zip", 1671 | "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/0411bde656dce64202b39c2f4473993a9081d39e", 1672 | "reference": "0411bde656dce64202b39c2f4473993a9081d39e", 1673 | "shasum": "" 1674 | }, 1675 | "require": { 1676 | "php": "^7.3" 1677 | }, 1678 | "type": "library", 1679 | "extra": { 1680 | "branch-alias": { 1681 | "dev-master": "3.0-dev" 1682 | } 1683 | }, 1684 | "autoload": { 1685 | "classmap": [ 1686 | "src/" 1687 | ] 1688 | }, 1689 | "notification-url": "https://packagist.org/downloads/", 1690 | "license": [ 1691 | "BSD-3-Clause" 1692 | ], 1693 | "authors": [ 1694 | { 1695 | "name": "Sebastian Bergmann", 1696 | "email": "sebastian@phpunit.de", 1697 | "role": "lead" 1698 | } 1699 | ], 1700 | "description": "Library that helps with managing the version number of Git-hosted PHP projects", 1701 | "homepage": "https://github.com/sebastianbergmann/version", 1702 | "time": "2020-01-21T06:36:37+00:00" 1703 | }, 1704 | { 1705 | "name": "symfony/polyfill-ctype", 1706 | "version": "v1.14.0", 1707 | "source": { 1708 | "type": "git", 1709 | "url": "https://github.com/symfony/polyfill-ctype.git", 1710 | "reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38" 1711 | }, 1712 | "dist": { 1713 | "type": "zip", 1714 | "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/fbdeaec0df06cf3d51c93de80c7eb76e271f5a38", 1715 | "reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38", 1716 | "shasum": "" 1717 | }, 1718 | "require": { 1719 | "php": ">=5.3.3" 1720 | }, 1721 | "suggest": { 1722 | "ext-ctype": "For best performance" 1723 | }, 1724 | "type": "library", 1725 | "extra": { 1726 | "branch-alias": { 1727 | "dev-master": "1.14-dev" 1728 | } 1729 | }, 1730 | "autoload": { 1731 | "psr-4": { 1732 | "Symfony\\Polyfill\\Ctype\\": "" 1733 | }, 1734 | "files": [ 1735 | "bootstrap.php" 1736 | ] 1737 | }, 1738 | "notification-url": "https://packagist.org/downloads/", 1739 | "license": [ 1740 | "MIT" 1741 | ], 1742 | "authors": [ 1743 | { 1744 | "name": "Gert de Pagter", 1745 | "email": "BackEndTea@gmail.com" 1746 | }, 1747 | { 1748 | "name": "Symfony Community", 1749 | "homepage": "https://symfony.com/contributors" 1750 | } 1751 | ], 1752 | "description": "Symfony polyfill for ctype functions", 1753 | "homepage": "https://symfony.com", 1754 | "keywords": [ 1755 | "compatibility", 1756 | "ctype", 1757 | "polyfill", 1758 | "portable" 1759 | ], 1760 | "time": "2020-01-13T11:15:53+00:00" 1761 | }, 1762 | { 1763 | "name": "theseer/tokenizer", 1764 | "version": "1.1.3", 1765 | "source": { 1766 | "type": "git", 1767 | "url": "https://github.com/theseer/tokenizer.git", 1768 | "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9" 1769 | }, 1770 | "dist": { 1771 | "type": "zip", 1772 | "url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9", 1773 | "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9", 1774 | "shasum": "" 1775 | }, 1776 | "require": { 1777 | "ext-dom": "*", 1778 | "ext-tokenizer": "*", 1779 | "ext-xmlwriter": "*", 1780 | "php": "^7.0" 1781 | }, 1782 | "type": "library", 1783 | "autoload": { 1784 | "classmap": [ 1785 | "src/" 1786 | ] 1787 | }, 1788 | "notification-url": "https://packagist.org/downloads/", 1789 | "license": [ 1790 | "BSD-3-Clause" 1791 | ], 1792 | "authors": [ 1793 | { 1794 | "name": "Arne Blankerts", 1795 | "email": "arne@blankerts.de", 1796 | "role": "Developer" 1797 | } 1798 | ], 1799 | "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", 1800 | "time": "2019-06-13T22:48:21+00:00" 1801 | }, 1802 | { 1803 | "name": "webmozart/assert", 1804 | "version": "1.7.0", 1805 | "source": { 1806 | "type": "git", 1807 | "url": "https://github.com/webmozart/assert.git", 1808 | "reference": "aed98a490f9a8f78468232db345ab9cf606cf598" 1809 | }, 1810 | "dist": { 1811 | "type": "zip", 1812 | "url": "https://api.github.com/repos/webmozart/assert/zipball/aed98a490f9a8f78468232db345ab9cf606cf598", 1813 | "reference": "aed98a490f9a8f78468232db345ab9cf606cf598", 1814 | "shasum": "" 1815 | }, 1816 | "require": { 1817 | "php": "^5.3.3 || ^7.0", 1818 | "symfony/polyfill-ctype": "^1.8" 1819 | }, 1820 | "conflict": { 1821 | "vimeo/psalm": "<3.6.0" 1822 | }, 1823 | "require-dev": { 1824 | "phpunit/phpunit": "^4.8.36 || ^7.5.13" 1825 | }, 1826 | "type": "library", 1827 | "autoload": { 1828 | "psr-4": { 1829 | "Webmozart\\Assert\\": "src/" 1830 | } 1831 | }, 1832 | "notification-url": "https://packagist.org/downloads/", 1833 | "license": [ 1834 | "MIT" 1835 | ], 1836 | "authors": [ 1837 | { 1838 | "name": "Bernhard Schussek", 1839 | "email": "bschussek@gmail.com" 1840 | } 1841 | ], 1842 | "description": "Assertions to validate method input/output with nice error messages.", 1843 | "keywords": [ 1844 | "assert", 1845 | "check", 1846 | "validate" 1847 | ], 1848 | "time": "2020-02-14T12:15:55+00:00" 1849 | } 1850 | ], 1851 | "aliases": [], 1852 | "minimum-stability": "stable", 1853 | "stability-flags": { 1854 | "league/flysystem": 15, 1855 | "league/flysystem-memory": 15 1856 | }, 1857 | "prefer-stable": false, 1858 | "prefer-lowest": false, 1859 | "platform": [], 1860 | "platform-dev": [] 1861 | } 1862 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ./src 6 | 7 | 8 | 9 | 10 | 11 | ./src 12 | 13 | ./src 14 | ./src 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/ConcreteDependencies/Invoice.php: -------------------------------------------------------------------------------- 1 | clientId = $clientId; 19 | $this->amount = $amount; 20 | $this->invoicePeriod = $invoicePeriod; 21 | } 22 | 23 | public function clientId(): string 24 | { 25 | return $this->clientId; 26 | } 27 | 28 | public function amount(): int 29 | { 30 | return $this->amount; 31 | } 32 | 33 | public function invoicePeriod(): InvoicePeriod 34 | { 35 | return $this->invoicePeriod; 36 | } 37 | 38 | /** 39 | * @inheritDoc 40 | */ 41 | public function jsonSerialize(): array 42 | { 43 | return [ 44 | 'client_id' => $this->clientId, 45 | 'amount' => $this->amount, 46 | 'invoice_period' => $this->invoicePeriod, 47 | ]; 48 | } 49 | 50 | public static function fromJsonPayload(array $payload): Invoice 51 | { 52 | return new Invoice( 53 | $payload['client_id'], 54 | $payload['amount'], 55 | InvoicePeriod::fromJsonPayload($payload['invoice_period']), 56 | ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/ConcreteDependencies/InvoicePeriod.php: -------------------------------------------------------------------------------- 1 | year = $year; 16 | $this->month = $month; 17 | } 18 | 19 | public function year(): int 20 | { 21 | return $this->year; 22 | } 23 | 24 | public function month(): int 25 | { 26 | return $this->month; 27 | } 28 | 29 | 30 | 31 | /** 32 | * @inheritDoc 33 | */ 34 | public function jsonSerialize() 35 | { 36 | return ['year' => $this->year, 'month' => $this->month]; 37 | } 38 | 39 | public static function fromDateTime(DateTimeInterface $dateTime): InvoicePeriod 40 | { 41 | return new InvoicePeriod((int) $dateTime->format('Y'), (int) $dateTime->format('m')); 42 | } 43 | 44 | public static function fromJsonPayload(array $payload): InvoicePeriod 45 | { 46 | return new InvoicePeriod($payload['year'], $payload['month']); 47 | } 48 | 49 | public function toString(): string 50 | { 51 | return sprintf('%d/%d', $this->year, $this->month); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/ConcreteDependencies/InvoiceService.php: -------------------------------------------------------------------------------- 1 | storage = $storage; 15 | } 16 | 17 | public function invoiceClient(string $clientId, InvoicePeriod $period): void 18 | { 19 | $cost = $this->calculateCosts($clientId, $period); 20 | $invoice = new Invoice($clientId, $cost, $period); 21 | 22 | try { 23 | $path = '/invoices/' . $clientId . '/' . $period->toString() . '.txt'; 24 | $this->storage->write($path, json_encode($invoice)); 25 | } catch (UnableToWriteFile $exception) { 26 | throw new UnableToInvoiceClient("Unable to upload the invoice.", 0, $exception); 27 | } 28 | } 29 | 30 | public function calculateCosts(string $clientId, InvoicePeriod $period): int 31 | { 32 | return 42; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/ConcreteDependencies/InvoiceServiceTest.php: -------------------------------------------------------------------------------- 1 | expectNotToPerformAssertions(); 20 | 21 | $mock = Mockery::mock(Filesystem::class); 22 | $mock->shouldReceive('write') 23 | ->once() 24 | ->with('/invoices/abc/2020/3.txt', '{"client_id":"abc","amount":42,"invoice_period":{"year":2020,"month":3}}'); 25 | 26 | $invoicePeriod = InvoicePeriod::fromDateTime(DateTimeImmutable::createFromFormat('!Y-m', '2020-03')); 27 | $invoiceService = new InvoiceService($mock); 28 | $invoiceService->invoiceClient('abc', $invoicePeriod); 29 | } 30 | 31 | /** 32 | * @test 33 | */ 34 | public function invoicing_the_client(): void 35 | { 36 | $storage = new Filesystem(new InMemoryFilesystemAdapter()); 37 | 38 | $invoicePeriod = InvoicePeriod::fromDateTime(DateTimeImmutable::createFromFormat('!Y-m', '2020-03')); 39 | $invoiceService = new InvoiceService($storage); 40 | $invoiceService->invoiceClient('abc', $invoicePeriod); 41 | 42 | $expectedContents = '{"client_id":"abc","amount":42,"invoice_period":{"year":2020,"month":3}}'; 43 | $this->assertTrue($storage->fileExists('/invoices/abc/2020/3.txt')); 44 | $this->assertEquals($expectedContents, $storage->read('/invoices/abc/2020/3.txt')); 45 | } 46 | 47 | protected function tearDown(): void 48 | { 49 | Mockery::close(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/ConcreteDependencies/UnableToInvoiceClient.php: -------------------------------------------------------------------------------- 1 | dependency = $dependency; 14 | } 15 | 16 | public function performOperation(): string 17 | { 18 | return $this->dependency->oldMethodName('some_argument'); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/DifficultToRenameWithMocks/DependingCodeTest.php: -------------------------------------------------------------------------------- 1 | shouldReceive('oldMethodName') 19 | ->with('some_argument') 20 | ->andReturn('some_response'); 21 | 22 | $dependingCode = new DependingCode($mock); 23 | $response = $dependingCode->performOperation(); 24 | 25 | $this->assertEquals('some_response', $response); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/DifficultToRenameWithMocks/ExternalDependency.php: -------------------------------------------------------------------------------- 1 | failNextSubmission) { 18 | $this->failNextSubmission = false; 19 | throw new UnableToInvoiceClient("Failed to submit the invoice."); 20 | } 21 | 22 | $this->submitInvoices[] = $invoice; 23 | } 24 | 25 | public function wasInvoiceSubmit(Invoice $invoice): bool 26 | { 27 | return in_array($invoice, $this->submitInvoices, false); 28 | } 29 | 30 | public function failNextSubmission() 31 | { 32 | $this->failNextSubmission = true; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/InterfacedDependencies/FakeInvoicePortalTest.php: -------------------------------------------------------------------------------- 1 | [function() { 19 | $invoicePortal = new FakeInvoicePortal(); 20 | $invoicePortal->failNextSubmission(); 21 | 22 | return $invoicePortal; 23 | }]; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/InterfacedDependencies/FlysystemInvoicePortal.php: -------------------------------------------------------------------------------- 1 | filesystem = $filesystemWriter; 18 | } 19 | 20 | public function submitInvoice(Invoice $invoice): void 21 | { 22 | $json = json_encode($invoice); 23 | $path = sprintf('/invoices/%s/%s.txt', $invoice->clientId(), $invoice->invoicePeriod()->toString()); 24 | 25 | try { 26 | $this->filesystem->write($path, $json); 27 | } catch (FilesystemOperationFailed $exception) { 28 | throw new UnableToInvoiceClient("Unable to upload invoice to portal", 0, $exception); 29 | } 30 | } 31 | 32 | public function wasInvoiceSubmit(Invoice $invoice): bool 33 | { 34 | $path = sprintf('/invoices/%s/%s.txt', $invoice->clientId(), $invoice->invoicePeriod()->toString()); 35 | 36 | try { 37 | $contents = $this->filesystem->read($path); 38 | } catch (UnableToReadFile $exception) { 39 | return false; 40 | } 41 | 42 | $storedInvoice = Invoice::fromJsonPayload(json_decode($contents, true)); 43 | 44 | // Compare by value for VO equality. 45 | return $invoice == $storedInvoice; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/InterfacedDependencies/FlysystemInvoicePortalTest.php: -------------------------------------------------------------------------------- 1 | [function() { 22 | return new FlysystemInvoicePortal(new Filesystem(new LocalFilesystemAdapter('/'))); 23 | }]; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/InterfacedDependencies/Invoice.php: -------------------------------------------------------------------------------- 1 | clientId = $clientId; 19 | $this->amount = $amount; 20 | $this->invoicePeriod = $invoicePeriod; 21 | } 22 | 23 | public function clientId(): string 24 | { 25 | return $this->clientId; 26 | } 27 | 28 | public function invoicePeriod(): InvoicePeriod 29 | { 30 | return $this->invoicePeriod; 31 | } 32 | 33 | /** 34 | * @inheritDoc 35 | */ 36 | public function jsonSerialize(): array 37 | { 38 | return [ 39 | 'client_id' => $this->clientId, 40 | 'amount' => $this->amount, 41 | 'invoice_period' => $this->invoicePeriod, 42 | ]; 43 | } 44 | 45 | public static function fromJsonPayload(array $payload): Invoice 46 | { 47 | return new Invoice( 48 | $payload['client_id'], 49 | $payload['amount'], 50 | InvoicePeriod::fromJsonPayload($payload['invoice_period']), 51 | ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/InterfacedDependencies/InvoicePeriod.php: -------------------------------------------------------------------------------- 1 | year = $year; 16 | $this->month = $month; 17 | } 18 | 19 | public function jsonSerialize() 20 | { 21 | return ['year' => $this->year, 'month' => $this->month]; 22 | } 23 | 24 | public static function fromDateTime(DateTimeInterface $dateTime): InvoicePeriod 25 | { 26 | return new InvoicePeriod((int) $dateTime->format('Y'), (int) $dateTime->format('m')); 27 | } 28 | 29 | public static function fromJsonPayload(array $payload): InvoicePeriod 30 | { 31 | return new InvoicePeriod($payload['year'], $payload['month']); 32 | } 33 | 34 | public function toString(): string 35 | { 36 | return sprintf('%d/%d', $this->year, $this->month); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/InterfacedDependencies/InvoicePortal.php: -------------------------------------------------------------------------------- 1 | createInvoicePortal(); 22 | $invoicePeriod = InvoicePeriod::fromDateTime(DateTimeImmutable::createFromFormat('!Y-m', '2020-03')); 23 | $invoice = new Invoice('abc', 42, $invoicePeriod); 24 | 25 | // Act 26 | $invoicePortal->submitInvoice($invoice); 27 | 28 | // Assert 29 | $this->assertTrue($invoicePortal->wasInvoiceSubmit($invoice)); 30 | } 31 | 32 | /** 33 | * @test 34 | */ 35 | public function detecting_if_an_invoice_was_NOT_submitted(): void 36 | { 37 | // Arrange 38 | $invoicePortal = $this->createInvoicePortal(); 39 | $invoicePeriod = InvoicePeriod::fromDateTime(DateTimeImmutable::createFromFormat('!Y-m', '2020-03')); 40 | $invoice = new Invoice('abc', 42, $invoicePeriod); 41 | 42 | // Act 43 | $wasInvoiceSubmitted = $invoicePortal->wasInvoiceSubmit($invoice); 44 | 45 | // Assert 46 | $this->assertFalse($wasInvoiceSubmitted); 47 | } 48 | 49 | /** 50 | * @test 51 | * @dataProvider scenariosCausingSubmitFailure 52 | */ 53 | public function failing_to_submit_an_invoice(callable $scenario): void 54 | { 55 | // Expect 56 | $this->expectException(UnableToInvoiceClient::class); 57 | 58 | // Arrange 59 | /** @var InvoicePortal $invoicePortal */ 60 | $invoicePortal = $scenario(); 61 | $invoicePeriod = InvoicePeriod::fromDateTime(DateTimeImmutable::createFromFormat('!Y-m', '2020-03')); 62 | $invoice = new Invoice('abc', 112, $invoicePeriod); 63 | 64 | // Act 65 | $invoicePortal->submitInvoice($invoice); 66 | } 67 | 68 | abstract public function scenariosCausingSubmitFailure(): Generator; 69 | } 70 | -------------------------------------------------------------------------------- /src/InterfacedDependencies/InvoiceService.php: -------------------------------------------------------------------------------- 1 | portal = $portal; 15 | } 16 | 17 | public function invoiceClient(string $clientId, InvoicePeriod $period): void 18 | { 19 | $cost = $this->calculateCosts($clientId, $period); 20 | $invoice = new Invoice($clientId, $cost, $period); 21 | $this->portal->submitInvoice($invoice); 22 | } 23 | 24 | private function calculateCosts(string $clientId, InvoicePeriod $period): int 25 | { 26 | return 42; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/InterfacedDependencies/InvoiceServiceTest.php: -------------------------------------------------------------------------------- 1 | invoiceClient('abc', $invoicePeriod); 24 | 25 | // Assert 26 | $expectedInvoice = new Invoice('abc', 42, $invoicePeriod); 27 | $this->assertTrue($invoicePortal->wasInvoiceSubmit($expectedInvoice)); 28 | } 29 | 30 | /** 31 | * @test 32 | */ 33 | public function failing_to_invoice_a_client(): void 34 | { 35 | // Expect 36 | $this->expectException(UnableToInvoiceClient::class); 37 | 38 | // Arrange 39 | $invoicePortal = new FakeInvoicePortal(); 40 | $invoicePortal->failNextSubmission(); 41 | $invoiceService = new InvoiceService($invoicePortal); 42 | $invoicePeriod = InvoicePeriod::fromDateTime(DateTimeImmutable::createFromFormat('!Y-m', '2020-03')); 43 | 44 | // Act 45 | $invoiceService->invoiceClient('abc', $invoicePeriod); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/InterfacedDependencies/UnableToInvoiceClient.php: -------------------------------------------------------------------------------- 1 |