我在symfony 2中有关于behat的问题。我有两个实体:
//交易
DM \ MultiStepFormBundle \ Entity \ Transaction: 类型:实体 repositoryClass:DM \ MultiStepFormBundle \ Repository \ Transaction \ TransactionRepository 表格:rb_multistepform_transaction
indexes:
transaction_id_index:
columns: [ transaction_id ]
id:
id:
type: integer
generator: { strategy: AUTO }
fields:
created_at:
type: datetime
nullable: false
transaction_id:
type: string
length: 128
nullable: false
is_client_new:
type: boolean
options:
default: false
utm_source:
type: string
length: 255
nullable: true
utm_medium:
type: string
length: 255
nullable: true
utm_campaign:
type: string
length: 255
nullable: true
user_agent:
type: text
nullable: true
http_referer:
type: string
length: 255
nullable: true
ip:
type: string
length: 32
nullable: true
status:
type: smallint
nullable: false
options:
default: 0
continue_service_run:
type: boolean
nullable: false
options:
default: false
continue_serivce_run_datetime:
type: datetime
nullable: true
oneToMany:
items:
targetEntity: DM\MultiStepFormBundle\Entity\TransactionItem
mappedBy: transaction
cascade: [persist, merge, remove]
manyToOne:
client:
targetEntity: DM\KlienciBundle\Entity\Client
inversedBy: multistepform_transactions
joinColumn:
name: client_id
referencedColumnName: id
// TransactionItem
DM\MultiStepFormBundle\Entity\TransactionItem:
type: entity
repositoryClass: DM\MultiStepFormBundle\Repository\Transaction\TransactionRepository
table: rb_multistepform_transaction_item
id:
id:
type: integer
generator: { strategy: AUTO }
indexes:
partner_status_index:
columns: [ partner_name, status ]
fields:
type:
type: smallint
nullable: false
partner_name:
type: string
length: 128
nullable: true
status:
type: smallint
nullable: false
options:
default: 0
link_id:
type: integer
nullable: true
product_id:
type: integer
nullable: true
pixelconversion_hash:
type: string
length: 128
nullable: true
partner_api_response:
type: json_array
nullable: true
clicked:
type: boolean
nullable: false
options:
default: 0
clicked_datetime:
type: datetime
nullable: true
order_nr:
type: integer
nullable: true
highlighted:
type: boolean
nullable: false
options:
default: false
manyToOne:
transaction:
targetEntity: DM\MultiStepFormBundle\Entity\Transaction
inversedBy: items
cascade: [persist, merge, remove]
joinColumn:
name: transaction_id
referencedColumnName: id
当我测试具有此类循环的服务时:
$ transactions = $ this-> transactionRepository-> getTransactionsByContinueServiceRunInDateRange(0,$ minDateTime,$ maxDateTime);
foreach ($transactions as $transactionKey => $singleTransaction) {
//in this place, relationships are not taken
$transactionItems = $singleTransaction->getItems();
//when it performs a test query items are downloaded correctly
$transactionItemsQuery = $this->transactionRepository->getItems($singleTransaction->getId());
}
我需要从反向关系中获取项目。使用symfony正常拨打该网站后,关系是正确的,一切都很好。 在behat中激活测试的情况下,变量$ transactionItems中的关系是一个空集合。该数据肯定存在于数据库中,因为在从查询中获取数据时,在变量$ transactionItemsQuery中,我具有正确的数据。
有没有人在behat中遇到过类似的事情?