Created
March 5, 2012 11:25
-
-
Save suin/1977931 to your computer and use it in GitHub Desktop.
【PHPUnitに詳しい人教えて!】 コンストラクタのテスト方法 ref: http://qiita.com/items/3008
This file contains hidden or 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 | |
class PDOTest extends \PHPUnit_Framework_TestCase | |
{ | |
public function test__construct() | |
{ | |
$pdo = $this | |
->getMockBuilder('\Suin\PDO') | |
->setMethods(array('_getDefaultAttributes')) | |
->disableOriginalConstructor() | |
->getMock(); | |
$pdo | |
->expects($this->once()) | |
->method('_getDefaultAttributes') | |
->will($this->returnValue(array())); | |
$pdo->__construct('mysql:host=127.0.0.1;dbname=testdb;charset=utf8;', 'root', 'root'); | |
} | |
} |
This file contains hidden or 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 PDOTest.php | |
PHPUnit 3.6.10 by Sebastian Bergmann. | |
E | |
Time: 0 seconds, Memory: 3.00Mb | |
There was 1 error: | |
1) Suin\PDOTest::test__construct | |
PDOException: You cannot serialize or unserialize PDO instances | |
/Users/suin/Desktop/PDOTest.php:44 | |
/Users/suin/.phpenv/versions/5.4.0pear/bin/phpunit:46 | |
FAILURES! | |
Tests: 1, Assertions: 0, Errors: 1. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment