Last active
July 31, 2017 05:21
-
-
Save masayuki5160/5a4d510164faa0516d4dd62b8388fe59 to your computer and use it in GitHub Desktop.
Dockerを使い手軽にPHPUnitをはじめる ref: http://qiita.com/masayuki5160/items/b305d5a19f3ec632f3e3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker pull php:5.6-apache | |
$ docker run -p 80:80 -v /(ホストの任意のパス)/:/var/www/html --name php56 -d php:5.6-apache | |
$ docker exec -ti php56 bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ apt-get update | |
$ apt-get install git vim | |
$ curl -sS https://getcomposer.org/installer | php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "phpunit", | |
"description": "PHPUnit", | |
"require": { | |
"phpunit/phpunit": "5.7.*" | |
}, | |
"config": { | |
"bin-dir": "/usr/local/bin/" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./composer.pha install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ php -v | |
PHP 5.6.31 (cli) (built: Jul 13 2017 18:38:40) | |
Copyright (c) 1997-2016 The PHP Group | |
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies | |
$ phpunit --v | |
PHPUnit 5.7.21 by Sebastian Bergmann and contributors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 2017/07/31 tadsanさんにコメント頂き修正(test/bootstrap.phpへ移した) | |
// require_once 'vendor/autoload.php'; | |
class firstTest extends PHPUnit_Framework_TestCase | |
{ | |
public function testMinimumViableTest() | |
{ | |
$this->assertTrue(false, "falseはtrueではない"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once __DIR__ . '/../vendor/autoload.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<phpunit> | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd" | |
backupGlobals="true" | |
backupStaticAttributes="false" | |
<!--bootstrap="/path/to/bootstrap.php"--> | |
cacheTokens="false" | |
colors="false" | |
convertErrorsToExceptions="true" | |
convertNoticesToExceptions="true" | |
convertWarningsToExceptions="true" | |
forceCoversAnnotation="false" | |
mapTestClassNameToCoveredClassName="false" | |
printerClass="PHPUnit_TextUI_ResultPrinter" | |
<!--printerFile="/path/to/ResultPrinter.php"--> | |
processIsolation="false" | |
stopOnError="false" | |
stopOnFailure="false" | |
stopOnIncomplete="false" | |
stopOnSkipped="false" | |
stopOnRisky="false" | |
testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader" | |
<!--testSuiteLoaderFile="/path/to/StandardTestSuiteLoader.php"--> | |
timeoutForSmallTests="1" | |
timeoutForMediumTests="10" | |
timeoutForLargeTests="60" | |
verbose="false"> | |
<testsuites> | |
<testsuite name="My Test Suite"> | |
<file>./firstTest.php</file> | |
</testsuite> | |
</testsuites> | |
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ phpunit -c phpunit.xml | |
PHPUnit 5.7.21 by Sebastian Bergmann and contributors. | |
F 1 / 1 (100%) | |
Time: 348 ms, Memory: 3.00MB | |
There was 1 failure: | |
1) firstTest::testMinimumViableTest | |
falseはtrueではない | |
Failed asserting that false is true. | |
/var/www/html/firstTest.php:9 | |
FAILURES! | |
Tests: 1, Assertions: 1, Failures: 1. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<phpunit> | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd" | |
backupGlobals="true" | |
backupStaticAttributes="false" | |
bootstrap="tests/bootstrap.php"<!-- 2017/07/31 tadsanさんにコメント頂き修正 --> | |
cacheTokens="false" | |
colors="false" | |
convertErrorsToExceptions="true" | |
convertNoticesToExceptions="true" | |
convertWarningsToExceptions="true" | |
forceCoversAnnotation="false" | |
mapTestClassNameToCoveredClassName="false" | |
printerClass="PHPUnit_TextUI_ResultPrinter" | |
<!--printerFile="/path/to/ResultPrinter.php"--> | |
processIsolation="false" | |
stopOnError="false" | |
stopOnFailure="false" | |
stopOnIncomplete="false" | |
stopOnSkipped="false" | |
stopOnRisky="false" | |
testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader" | |
<!--testSuiteLoaderFile="/path/to/StandardTestSuiteLoader.php"--> | |
timeoutForSmallTests="1" | |
timeoutForMediumTests="10" | |
timeoutForLargeTests="60" | |
verbose="false"> | |
<testsuites> | |
<testsuite name="My Test Suite"> | |
<file>./firstTest.php</file> | |
</testsuite> | |
</testsuites> | |
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ phpunit -c phpunit.xml | |
PHPUnit 5.7.21 by Sebastian Bergmann and contributors. | |
F 1 / 1 (100%) | |
Time: 348 ms, Memory: 3.00MB | |
There was 1 failure: | |
1) firstTest::testMinimumViableTest | |
falseはtrueではない | |
Failed asserting that false is true. | |
/var/www/html/firstTest.php:9 | |
FAILURES! | |
Tests: 1, Assertions: 1, Failures: 1. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment