์๊ณก๊ฐ.json์ require-dev ์น์ ์ phpunit์ ์ถ๊ฐํ์ฌ ์ค์นํ๋ฉด ์๋ํ์ง ์๋ ๊ฒ ๊ฐ์ต๋๋ค.
"require-dev": {
"phpunit/phpunit": "4.3.*"
}
์ด๊ฒ์ ํ์ฌ phpunit 4.3.5๋ฅผ ๊ฐ์ ธ์ค๋ ค๊ณ ์๋ํฉ๋๋ค. composer.json ํ์ผ์ bin-dir(bin/phpunit)์ phpunit์ ๋ํ ๋ฐ์ด๋๋ฆฌ๊ฐ ์์์ ์ง์ ํ์ง๋ง GitHub์ phpunit์ ๋ํ ์ฝ๋๋ ๊ทธ๋ฌํ ๋๋ ํ ๋ฆฌ๋ฅผ ํฌํจํ์ง ์์ผ๋ฉฐ ํจ์ฌ ๋ ์ ์ ์์ ํด๋น ๋๋ ํ ๋ฆฌ์ ์์ต๋๋ค. ๋ฐ๋ผ์ ํ๋ก์ ํธ ์์ค์์ bin/phpunit์ symlink๋ฅผ ์๋ํ๋ฉด ์ ์ด์ symlinkํ ํ์ผ์ด ์๊ธฐ ๋๋ฌธ์ ์คํจํฉ๋๋ค.
์ด๊ฒ์ ์ต์ ์์ฑ๊ธฐ PHAR์ ์ฌ์ฉํ๋ Ubuntu Linux ์์คํ ์ ์์ต๋๋ค. ์ค๋ฅ ์์ธ๊ฐ src/Composer/Installer/LibraryInstaller.php์ 246ํ์ ์๊ณ ์ค๋ฅ ๋ฉ์์ง๊ฐ "file_put_contents(/xxxxxx/bin/phpunit): ์คํจํ์ต๋๋ค. ์คํธ๋ฆผ ์ด๊ธฐ: ํด๋น ํ์ผ ๋๋ ๋๋ ํฐ๋ฆฌ๊ฐ ์์ต๋๋ค."(ํ๋ก์ ํธ ๋๋ ํฐ๋ฆฌ ๊ฒฝ๋ก๋ xxxxxx๊ฐ ์๋๋ฉฐ ์์ ๋์์ต๋๋ค).
๊ฐ์ฌ ํด์.
๋ฌธ์ ๊ฐ ๋ฌด์์ธ์ง ํ์คํ์ง ์์:
$ cat composer.json
{
"require-dev": {
"phpunit/phpunit": "4.3.*"
}
}
$ php composer.phar install
Loading composer repositories with package information
Installing dependencies (including require-dev)
- Installing sebastian/version (1.0.3)
Loading from cache
- Installing sebastian/exporter (1.0.2)
Loading from cache
- Installing sebastian/environment (1.2.0)
Loading from cache
- Installing sebastian/diff (1.2.0)
Loading from cache
- Installing sebastian/comparator (1.0.1)
Loading from cache
- Installing symfony/yaml (v2.5.6)
Loading from cache
- Installing doctrine/instantiator (1.0.4)
Loading from cache
- Installing phpunit/php-text-template (1.2.0)
Loading from cache
- Installing phpunit/phpunit-mock-objects (2.3.0)
Loading from cache
- Installing phpunit/php-timer (1.0.5)
Loading from cache
- Installing phpunit/php-file-iterator (1.3.4)
Loading from cache
- Installing phpunit/php-token-stream (1.3.0)
Loading from cache
- Installing phpunit/php-code-coverage (2.0.11)
Loading from cache
- Installing phpunit/phpunit (4.3.5)
Downloading: 100%
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
Writing lock file
Generating autoload files
$ ./vendor/bin/phpunit --version
PHPUnit 4.3.5 by Sebastian Bergmann.
๊ทํ์ ํ๋ก์ ํธ์ bin ๋๋ ํ ๋ฆฌ๊ฐ ํ์ํ๋ค๋ ๊ฐ์ ์ ๋ํด ์ฌ๊ณผ๋๋ฆฝ๋๋ค. ์ค๋ ์์นจ์ phpunit ์ ์ฅ์์ ๋ฃจํธ์ ์๋ phpunit ํ์ผ์ ํ์ธํ๊ธฐ ๋๋ฌธ์ ๋ด ๊ฐ์ ์ด ์ ํํ์ง ์์ต๋๋ค. ๋ง์ ์ฌ๊ณผ. ๊ทธ๋ฌ๋ ์ฌ์ ํ ๊ฐ์ ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค. ๊ทธ๋ฌ๋ ์๊ณก๊ฐ ์ค์น๋ฅผ ์ฌ์ฉํ์ฌ ์ฌ๋ฐ๋ฅด๊ฒ ์ค์นํ ์ ์์ผ๋ฏ๋ก ์ด ํฐ์ผ์ ๋ซ์ ๊ฒ์ ๋๋ค. ๊ทธ ๊ทผ๊ฑฐ๋ ์๋ชป๋ ๊ฐ์ ์ด๊ธฐ ๋๋ฌธ์ ๋๋ค. ๋ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ณ ๋ฌธ์ ์ ์์ค๋ฅผ ๋ฐ๊ฒฌํ๋ฉด ๋ฌธ์ ๊ฐ ์ค์ ๋ก phpunit๊ณผ ๊ด๋ จ๋ ๊ฒฝ์ฐ ์ ์ ํ๊ฒ ์ด๊ฑฐ๋ ๋ค์ ์ด ๊ฒ์ ๋๋ค. ๊ฐ์ฌ ํด์.
๋๋ ๋ด ๋ฌธ์ ์ ์์ธ์ ๋ฐ๊ฒฌํ๋ค๊ณ ์๊ฐํฉ๋๋ค. composer.json์๋ ๋ค์๊ณผ ๊ฐ์ ํญ๋ชฉ์ด ์์์ต๋๋ค.
"require-dev": {
"phpunit/phpunit": "~3.7"
}
๊ทธ๋ฆฌ๊ณ bin/phpunit์ ../vendor/phpunit/phpunit/composer/bin/phpunit์ ๊ฐ๋ฆฌํค๋ ์ฌ๋ณผ๋ฆญ ๋งํฌ์์ต๋๋ค.
์๊ณก๊ฐ ์ค์น๊ฐ ํด๋น ์ฌ๋ณผ๋ฆญ ๋งํฌ๋ฅผ ์ ๋ฐ์ดํธํ์ง ์์๊ณ ๊นจ์ง ์ฌ๋ณผ๋ฆญ ๋งํฌ ์ธ bin/phpunit์ ๋ด์ฉ์ ์ ๋ฐ์ดํธํ๋ ค๊ณ ์๋ํ์ ๋ ์คํจํ ๋ค์ createUnixyProxy ๋ฉ์๋๋ฅผ ์ฌ์ฉํ์ฌ ์ ๋ฐ์ดํธ๋ฅผ ์๋ํ์ง๋ง ๊นจ์ง ์ฌ๋ณผ๋ฆญ ๋งํฌ๋ก ์ธํด ์คํจํ์ต๋๋ค. phpunit ๋ฐ์ด๋๋ฆฌ๊ฐ 3.7์์ 4.0์ผ๋ก ๋ณ๊ฒฝ๋๋ฉด ์ ์ฌ์ ์ผ๋ก ์๊ณก๊ฐ๊ฐ ํผ๋๋ ์ ์์ง๋ง, ์๊ณก๊ฐ๋ ํ์ฌ ์ํํ๋ ๊ฒ๋ณด๋ค bin ํด๋์์ ๊นจ์ง ์ฌ๋ณผ๋ฆญ ๋งํฌ๋ฅผ ์ ๋ฐ์ดํธํด์ผ ํ ํ์์ฑ์ ์ฐ์ํ๊ฒ ์ฒ๋ฆฌํ ์ ์์ด์ผ ํ๋ค๊ณ ์๊ฐํฉ๋๋ค.
๊ฐ์ฌํฉ๋๋ค. ์๋ชป๋ ๋ณด๊ณ ๋ฅผ ํด์ ์ฃ์กํฉ๋๋ค.
์ค๋ ์ ํํ ๊ฐ์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ฌ bin ๋๋ ํ ๋ฆฌ๋ฅผ ์ ๊ฑฐํ์ฌ ํด๊ฒฐํ ์ ์์๊ธฐ ๋๋ฌธ์ ๋ฒ๊ทธ ๋ณด๊ณ ์์ ๋ํด ๋๋จํ ๊ฐ์ฌํฉ๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์ค๋ ์ ํํ ๊ฐ์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ฌ bin ๋๋ ํ ๋ฆฌ๋ฅผ ์ ๊ฑฐํ์ฌ ํด๊ฒฐํ ์ ์์๊ธฐ ๋๋ฌธ์ ๋ฒ๊ทธ ๋ณด๊ณ ์์ ๋ํด ๋๋จํ ๊ฐ์ฌํฉ๋๋ค.