本机symfony2服务doctrine.orm.entity_manager在使用phpUnit的单元测试方法中不起作用

时间:2016-03-14 11:28:32

标签: php symfony doctrine-orm phpunit

正如我在标题中提到的,当从单元测试方法请求doctrine.orm.entity_manager服务时,我仍然得到以下错误。请注意,我已经检查了我的架构和它的db是否已同步且架构是否有效。

我的单元测试方法:

public function testOneParByPollingStation()
{
    $statisticsHandler = $this->container->get('...__service_name__...');

    $em = $this->container->get('doctrine.orm.entity_manager');
    $party = $em->getRepository('..:Party')->findOneBy(array('name' => 'NDC'));

    $pollingStations = $em->getRepository('...:PollingStation2')->findAll();
}

运行单元测试时生成错误:

PHPUnit 5.1.4 by Sebastian Bergmann and contributors.

.....E                                                              6 / 6 (100%)

Time: 426 ms, Memory: 17.00Mb

There was 1 error:

1) Iballot\CmsBundle\Test\Component\StatisticsHandlerTest::testOneParByPollingStation
Doctrine\DBAL\Exception\InvalidFieldNameException: An exception occurred while executing 'SELECT t0.id AS id_1, t0.issueNumber AS issueNumber_2, t0.preFirstVerifier AS preFirstVerifier_3, t0.parlFirstVerifier AS parlFirstVerifier_4, t0.preEditedVotesProcess AS preEditedVotesProcess_5, t0.parEditedVotesProcess AS parEditedVotesProcess_6, t0.verfierNumber AS verfierNumber_7, t0.registeredVoters AS registeredVoters_8, t0.name AS name_9, t0.verifier_number AS verifier_number_10, t0.address AS address_11, t0.edited_result_id AS edited_result_id_12, t13.id AS id_14, t13.name AS name_15, t13.telephone AS telephone_16, t13.firstName AS firstName_17, t13.lastName AS lastName_18, t13.dob AS dob_19, t13.image AS image_20, t13.gender AS gender_21, t13.polling_station_id AS polling_station_id_22, t0.constituency_id AS constituency_id_23 FROM polling_station2 t0 LEFT JOIN representator t13 ON t13.polling_station_id = t0.id':

SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.edited_result_id' in 'field list'

polling_station2表格描述:

id
int(11)
NO
PRI
NULL
auto_increment
constituency_id
int(11)
NO
MUL
NULL
preFirstVerifier
tinyint(1)
YES
NULL
parlFirstVerifier
tinyint(1)
YES
NULL
verfierNumber
int(11)
YES
NULL
registeredVoters
int(11)
YES
NULL
name
varchar(255)
NO
NULL
verifier_number
varchar(255)
NO
NULL
address
varchar(255)
NO
NULL
issueNumber
int(11)
YES
NULL
preEditedVotesProcess
tinyint(1)
YES
NULL
parEditedVotesProcess
tinyint(1)
YES
NULL
edited_result_id
int(11)
YES
UNI
NULL

0 个答案:

没有答案