| @@ 102-117 (lines=16) @@ | ||
| 99 | * |
|
| 100 | * connect()成功時のテスト(DSN未指定時) |
|
| 101 | */ |
|
| 102 | public function test_Connect_Success1() |
|
| 103 | { |
|
| 104 | $params = [ |
|
| 105 | 'dsn' => '', |
|
| 106 | 'driver' => $GLOBALS[ 'DB_DRIVER' ], |
|
| 107 | 'user' => $GLOBALS[ 'DB_USER' ], |
|
| 108 | 'pass' => $GLOBALS[ 'DB_PASSWORD' ], |
|
| 109 | 'dbname' => $GLOBALS[ 'DB_DBNAME' ], |
|
| 110 | 'host' => $GLOBALS[ 'DB_HOST' ], |
|
| 111 | 'persistent' => false, |
|
| 112 | ]; |
|
| 113 | ||
| 114 | $instance = new Db; |
|
| 115 | $this->assertTrue( $instance->connect( $params ) ); |
|
| 116 | unset( $instance ); |
|
| 117 | } |
|
| 118 | ||
| 119 | /** |
|
| 120 | * test_Connect_Success2() |
|
| @@ 124-139 (lines=16) @@ | ||
| 121 | * |
|
| 122 | * connect()成功時のテスト(DSN指定時) |
|
| 123 | */ |
|
| 124 | public function test_Connect_Success2() |
|
| 125 | { |
|
| 126 | $params = [ |
|
| 127 | 'dsn' => $GLOBALS[ 'DB_DSN' ], |
|
| 128 | 'driver' => $GLOBALS[ 'DB_DRIVER' ], |
|
| 129 | 'user' => $GLOBALS[ 'DB_USER' ], |
|
| 130 | 'pass' => $GLOBALS[ 'DB_PASSWORD' ], |
|
| 131 | 'dbname' => $GLOBALS[ 'DB_DBNAME' ], |
|
| 132 | 'host' => $GLOBALS[ 'DB_HOST' ], |
|
| 133 | 'persistent' => false, |
|
| 134 | ]; |
|
| 135 | ||
| 136 | $instance = new Db; |
|
| 137 | $this->assertTrue( $instance->connect( $params ) ); |
|
| 138 | unset( $instance ); |
|
| 139 | } |
|
| 140 | ||
| 141 | /** |
|
| 142 | * test_Connect_Success3() |
|
| @@ 146-161 (lines=16) @@ | ||
| 143 | * |
|
| 144 | * connect()成功時のテスト(DSN未指定、オプション指定) |
|
| 145 | */ |
|
| 146 | public function test_Connect_Success3() |
|
| 147 | { |
|
| 148 | $params = [ |
|
| 149 | 'dsn' => '', |
|
| 150 | 'driver' => $GLOBALS[ 'DB_DRIVER' ], |
|
| 151 | 'user' => $GLOBALS[ 'DB_USER' ], |
|
| 152 | 'pass' => $GLOBALS[ 'DB_PASSWORD' ], |
|
| 153 | 'dbname' => $GLOBALS[ 'DB_DBNAME' ], |
|
| 154 | 'host' => $GLOBALS[ 'DB_HOST' ], |
|
| 155 | 'persistent' => false, |
|
| 156 | ]; |
|
| 157 | ||
| 158 | $instance = new Db; |
|
| 159 | $this->assertTrue( $instance->connect( $params, [ \PDO::ATTR_PERSISTENT => false ] ) ); |
|
| 160 | unset( $instance ); |
|
| 161 | } |
|
| 162 | ||
| 163 | /** |
|
| 164 | * test_Connect_Failure() |
|
| @@ 102-117 (lines=16) @@ | ||
| 99 | * |
|
| 100 | * disConnect()のテスト(force未設定時) |
|
| 101 | */ |
|
| 102 | public function test_DisConnect() |
|
| 103 | { |
|
| 104 | $params = [ |
|
| 105 | "driver" => $GLOBALS[ 'DB_DRIVER' ], |
|
| 106 | "user" => $GLOBALS[ 'DB_USER' ], |
|
| 107 | "pass" => $GLOBALS[ 'DB_PASSWORD' ], |
|
| 108 | "dbname" => $GLOBALS[ 'DB_DBNAME' ], |
|
| 109 | "host" => $GLOBALS[ 'DB_HOST' ], |
|
| 110 | "persistent" => false, |
|
| 111 | ]; |
|
| 112 | ||
| 113 | $instance = new Db; |
|
| 114 | $instance->connect( $params ); |
|
| 115 | $this->assertTrue( $instance->disConnect() ); |
|
| 116 | unset( $instance ); |
|
| 117 | } |
|
| 118 | ||
| 119 | /** |
|
| 120 | * test_DisConnect_with_force() |
|
| @@ 124-139 (lines=16) @@ | ||
| 121 | * |
|
| 122 | * disConnect()のテスト(force = true時) |
|
| 123 | */ |
|
| 124 | public function test_DisConnect_with_force() |
|
| 125 | { |
|
| 126 | $params = [ |
|
| 127 | "driver" => $GLOBALS[ 'DB_DRIVER' ], |
|
| 128 | "user" => $GLOBALS[ 'DB_USER' ], |
|
| 129 | "pass" => $GLOBALS[ 'DB_PASSWORD' ], |
|
| 130 | "dbname" => $GLOBALS[ 'DB_DBNAME' ], |
|
| 131 | "host" => $GLOBALS[ 'DB_HOST' ], |
|
| 132 | "persistent" => false, |
|
| 133 | ]; |
|
| 134 | ||
| 135 | $instance = new Db; |
|
| 136 | $instance->connect( $params ); |
|
| 137 | $this->assertTrue( $instance->disConnect( true ) ); |
|
| 138 | unset( $instance ); |
|
| 139 | } |
|
| 140 | ||
| 141 | /** |
|
| 142 | * test_DisConnect_without_force() |
|
| @@ 146-161 (lines=16) @@ | ||
| 143 | * |
|
| 144 | * disConnect()のテスト(force = false時) |
|
| 145 | */ |
|
| 146 | public function test_DisConnect_without_force() |
|
| 147 | { |
|
| 148 | $params = [ |
|
| 149 | "driver" => $GLOBALS[ 'DB_DRIVER' ], |
|
| 150 | "user" => $GLOBALS[ 'DB_USER' ], |
|
| 151 | "pass" => $GLOBALS[ 'DB_PASSWORD' ], |
|
| 152 | "dbname" => $GLOBALS[ 'DB_DBNAME' ], |
|
| 153 | "host" => $GLOBALS[ 'DB_HOST' ], |
|
| 154 | "persistent" => false, |
|
| 155 | ]; |
|
| 156 | ||
| 157 | $instance = new Db; |
|
| 158 | $instance->connect( $params ); |
|
| 159 | $this->assertTrue( $instance->disConnect( false ) ); |
|
| 160 | unset( $instance ); |
|
| 161 | } |
|
| 162 | } |
|
| 163 | ||