Phpunit: phpdbg์—์„œ ํ”„๋กœ์„ธ์Šค ๊ฒฉ๋ฆฌ๊ฐ€ ์˜ˆ์™ธ๋ฅผ throwํ•ฉ๋‹ˆ๋‹ค.

์— ๋งŒ๋“  2019๋…„ 11์›” 30์ผ  ยท  3์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: sebastianbergmann/phpunit

- ๋” ์ด์ƒ ์ง€์›๋˜์ง€ ์•Š๋Š” PHPUnit ๋ฒ„์ „์— ๋Œ€ํ•œ ๋ฌธ์ œ๋ฅผ ๋ณด๊ณ ํ•˜์ง€ ๋งˆ์‹ญ์‹œ์˜ค. ํ˜„์žฌ ์ง€์›๋˜๋Š” PHPUnit ๋ฒ„์ „ ๋ชฉ๋ก์€ https://phpunit.de/supported-versions.html์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. - ์‚ฌ์šฉ ์ค‘์ธ PHPUnit ๋ฒ„์ „์—์„œ ์ง€์›ํ•˜์ง€ ์•Š๋Š” PHP ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ ๋ฌธ์ œ๋ฅผ ๋ณด๊ณ ํ•˜์ง€ ๋งˆ์‹ญ์‹œ์˜ค. https://phpunit.de/supported-versions.html์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” PHPUnit ๋ฒ„์ „์ด ์ง€์›๋˜๋Š” PHP ๋ฒ„์ „์„ ๋ณด์—ฌ์ฃผ๋Š” ๋ชฉ๋ก์ž…๋‹ˆ๋‹ค. - ๋ฌธ์ œ์— ๋”ฐ๋ผ ์ด ํ…œํ”Œ๋ฆฟ์„ ์ž‘์„ฑํ•˜์‹ญ์‹œ์˜ค. - ๋ฌธ์ œ ์ƒ๋‹จ์— ์•„๋ž˜ ํ‘œ๋ฅผ ์œ ์ง€ํ•˜์‹ญ์‹œ์˜ค. - Composer๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ PHPUnit์„ ์„ค์น˜ํ•œ ๊ฒฝ์šฐ "composer info | sort"์˜ ์ถœ๋ ฅ์„ ํฌํ•จํ•˜์‹ญ์‹œ์˜ค. - ์ฝ”๋“œ๋ฅผ ํ…์ŠคํŠธ๋กœ ๊ฒŒ์‹œํ•˜์‹ญ์‹œ์˜ค(์ ์ ˆํ•œ ๋งˆํฌ์—… ์‚ฌ์šฉ). ์ฝ”๋“œ ์Šคํฌ๋ฆฐ์ƒท์„ ๊ฒŒ์‹œํ•˜์ง€ ๋งˆ์‹ญ์‹œ์˜ค. - ์ง€์›์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ https://phpunit.de/support.html์„ ๋ฐฉ๋ฌธํ•˜์‹ญ์‹œ์˜ค. - ๋ฌธ์ œ๋ฅผ ์ œ์ถœํ•˜๊ธฐ ์ „์— ์ด ๋Œ“๊ธ€์„ ์‚ญ์ œํ•˜์„ธ์š”.

| ์งˆ๋ฌธ | NS
| --------------------| ---------------
| PHPUnit ๋ฒ„์ „ | 8.4.3
| PHP ๋ฒ„์ „ | 7.4.0(phpdbg SAPI)
| ์„ค์น˜ ๋ฐฉ๋ฒ• | ์ž‘๊ณก๊ฐ€

์š”์•ฝ

ํ”„๋กœ์„ธ์Šค ๊ฒฉ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด phpdbg ์•„๋ž˜์—์„œ ์˜ˆ์™ธ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ์ฒ˜์Œ์—๋Š” #3772์˜ ํ‡ดํ–‰์ธ ์ค„ ์•Œ์•˜๋Š”๋ฐ, ๋ณ„๊ฐœ์˜ ์›์ธ์ธ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

TestCaseMethod.tpl ์—์„œ ์ด ์ค„ ๊นŒ์ง€ ๋ฒ„๊ทธ๋ฅผ ์ถ”์ ํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค ( TestCaseClass.tpl ์—๋„ ์œ ์‚ฌํ•œ ์ฝ”๋“œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค). ์ด ๋‘ ์ค„์€ ์ฝ์„ ์ˆ˜ ์žˆ๋Š” ์ŠคํŠธ๋ฆผ์ธ์ง€ ๋จผ์ € ํ™•์ธํ•˜์ง€ ์•Š๊ณ  STDOUT ์—์„œ ์ฝ์œผ๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

stream_get_meta_data(STDOUT) ์‚ฌ์šฉํ•˜์—ฌ ๋””๋ฒ„๊ทธ ๋ฌธ์„ ์ž…๋ ฅํ•˜๋ฉด STDOUT ๋ฅผ ์ฝ์„ ์ˆ˜ ์—†์Œ์„ ์•Œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

array(9) {
  ["timed_out"]=>
  bool(false)
  ["blocked"]=>
  bool(true)
  ["eof"]=>
  bool(false)
  ["wrapper_type"]=>
  string(3) "PHP"
  ["stream_type"]=>
  string(5) "STDIO"
  ["mode"]=>
  string(2) "wb"
  ["unread_bytes"]=>
  int(0)
  ["seekable"]=>
  bool(false)
  ["uri"]=>
  string(12) "php://stdout"
}

๋˜ํ•œ๋ณด์‹ญ์‹œ์˜ค:

ํ˜„์žฌ ํ–‰๋™

phpdbg ์—์„œ ํ”„๋กœ์„ธ์Šค ๊ฒฉ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ํ…Œ์ŠคํŠธ๋Š” ์‹คํ–‰๋˜์ง€ ์•Š๊ณ  ๋Œ€์‹  PHPUnit\Framework\Exception: Notice: stream_get_contents(): read of 8192 bytes failed with errno=9 Bad file descriptor in Standard input code on line 336 ์™€ ์œ ์‚ฌํ•œ ์˜ˆ์™ธ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

๋ฒˆ์‹ ๋ฐฉ๋ฒ•

phpdbg ์•„๋ž˜์—์„œ ์ด ํ…Œ์ŠคํŠธ๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

<?php

use PHPUnit\Framework\TestCase;

class ReproTest extends TestCase
{
    /**
     * <strong i="20">@doesNotPerformAssertions</strong>
     * <strong i="21">@runInSeparateProcess</strong>
     */
    public function testProcessIsolation()
    {
    }
}

๊ทธ๋ฆฌ๊ณ  ์ด ์ถœ๋ ฅ์„ ๋ณด์‹ญ์‹œ์˜ค:

$ phpdbg -qrr vendor/bin/phpunit
PHPUnit 8.4.3 by Sebastian Bergmann and contributors.

E                                                                   1 / 1 (100%)

Time: 121 ms, Memory: 6.00 MB

There was 1 error:

1) ReproTest::testProcessIsolation
PHPUnit\Framework\Exception: Notice: stream_get_contents(): read of 8192 bytes failed with errno=9 Bad file descriptor in Standard input code on line 336

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

์˜ˆ์ƒ๋˜๋Š” ํ–‰๋™

ํ”„๋กœ์„ธ์Šค ๊ฒฉ๋ฆฌ๋Š” ๋‹ค๋ฅธ PHP SAPI์—์„œ์™€ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ phpdbg ์—์„œ ์ž‘๋™ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

composer info | sort ์ถœ๋ ฅ

doctrine/instantiator              1.3.0   A small, lightweight utility to instantiate objects in PHP without invoking their constructors
myclabs/deep-copy                  1.9.3   Create deep copies (clones) of your objects
phar-io/manifest                   1.0.3   Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version                    2.0.1   Library for handling version information and constraints
phpdocumentor/reflection-common    2.0.0   Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock  4.3.2   With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.
phpdocumentor/type-resolver        1.0.1   A PSR-5 based resolver of Class names, Types and Structural Element Names
phpspec/prophecy                   1.9.0   Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage          7.0.10  Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator          2.0.2   FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-text-template          1.2.1   Simple template engine.
phpunit/php-timer                  2.1.2   Utility class for timing
phpunit/php-token-stream           3.1.1   Wrapper around PHP's tokenizer extension.
phpunit/phpunit                    8.4.3   The PHP Unit Testing framework.
sebastian/code-unit-reverse-lookup 1.0.1   Looks up which function or method a line of code belongs to
sebastian/comparator               3.0.2   Provides the functionality to compare PHP values for equality
sebastian/diff                     3.0.2   Diff implementation
sebastian/environment              4.2.3   Provides functionality to handle HHVM/PHP environments
sebastian/exporter                 3.1.2   Provides the functionality to export PHP variables for visualization
sebastian/global-state             3.0.0   Snapshotting of global state
sebastian/object-enumerator        3.0.3   Traverses array structures and object graphs to enumerate all referenced objects
sebastian/object-reflector         1.1.1   Allows reflection of object attributes, including inherited and non-public ones
sebastian/recursion-context        3.0.0   Provides functionality to recursively process PHP variables
sebastian/resource-operations      2.0.1   Provides a list of PHP built-in functions that operate on resources
sebastian/type                     1.1.3   Collection of value objects that represent the types of the PHP type system
sebastian/version                  2.0.1   Library that helps with managing the version number of Git-hosted PHP projects
symfony/polyfill-ctype             v1.13.0 Symfony polyfill for ctype functions
theseer/tokenizer                  1.1.3   A small library for converting tokenized PHP source code into XML and potentially other formats
webmozart/assert                   1.6.0   Assertions to validate method input/output with nice error messages.
featurprocess-isolation typbug

๋ชจ๋“  3 ๋Œ“๊ธ€

ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

PHPDBG์—๋งŒ ์˜ํ–ฅ์„ ๋ฏธ์น˜๋Š” ๋ฌธ์ œ๋ฅผ ๋””๋ฒ„๊น…ํ•˜๋Š” ๋ฐ ์‹œ๊ฐ„์„ ํˆฌ์žํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์†”์งํžˆ ๋งํ•ด์„œ, PHPUnit ์ž์ฒด๋ฟ๋งŒ ์•„๋‹ˆ๋ผ php-code-coverage์—์„œ ์ง€์›์„ ์ œ๊ฑฐํ•˜๋Š” ๊ฒƒ์— ๋Œ€ํ•ด ์ƒ๊ฐํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด ์ผ๋ฐ˜ PHP๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ์ŠคํŠธ๋ฆผ์„ ์ฝ์„ ์ˆ˜ ์—†๋Š” ๊ฒƒ์œผ๋กœ ๋ณด๊ณ ํ•ฉ๋‹ˆ๋‹ค.

php -r 'echo stream_get_meta_data(STDOUT)["mode"], "\n";' | cat
// Outputs: wb

์ด ๋ฌธ์ œ ๋Š” PHP 7.4.0์—์„œ ์ฒ˜์Œ ๋‚˜ํƒ€๋‚ฌ์Šต๋‹ˆ๋‹ค . ์ด๊ฒƒ์€ PHP ๋ฒ„๊ทธ ์ผ ์ˆ˜ ์žˆ์ง€๋งŒ ๋” ์ž˜ ๋ชจ๋ฅด๊ฒ ์Šต๋‹ˆ๋‹ค.

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰