ini for the application. We use
the [test] section to specify our test database as shown in Listing 5.9.
Listing 5.9: The [test] section overrides [general] in application/config.ini.
[general] |#1
db.adapter = PDO_MYSQL |
db.config.host = localhost |
db.config.username = zfia |
db.config.password = 123456 |
db.config.dbname = places |
[test : general] #2
db.config.dbname = places_test #3
(annotation) <#1. [general] contains the main database connection infomation.>
(annotation) <#2. [test] overrides [general].>
(annotation) <#3. Override the database name when testing.>
In our case, we only need to change the database name from places to places_test; we can rely on the other
settings in the general section to provide the other connection information. We are now in a position to create
the unit test class skeleton as shown in Listing 5.10.
Listing 5.10: tests/models/UsersTests.php
require_once 'PHPUnit/Framework.php';
if(!defined('ROOT_DIR')) {
define('ROOT_DIR', dirname(dirname(dirname(__FILE__)))); |#1
|
set_include_path('.' |
. PATH_SEPARATOR . ROOT_DIR . '/library' |
. PATH_SEPARATOR . ROOT_DIR . '/../../lib/zf/library' |
. PATH_SEPARATOR . ROOT_DIR . '/application/models' |
. PATH_SEPARATOR . get_include_path()); |
}
Licensed to Menshu You
Pages:
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169