symfony - 行为测试中的 Symfony 学说空关系
问题描述
我在 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
//事务项
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 中,当我从查询中获取数据时,我有正确的数据。
有没有人遇到过类似的事情?
解决方案
推荐阅读
- reactjs - 使用 MaterialTopTabNavigator 时 undefined is not a function (near '...'createRouter...') 错误
- ios - 动态调整 TableViewController Cell 的大小
- android - Livedata 数据变化模式
- python - Django Signals - 在模型创建时创建文件夹
- javascript - jQuery $(this).data() 返回未定义
- php - 作曲家在linux上给出openssl错误消息php7
- html - 如何在使用flutter_html插件的flutter中自定义UL > LI
- flutter - 颤振条子列表标签栏底部溢出错误
- c - 实现一个 C 函数,该函数在给定字符上拆分字符串并在拆分后返回字符串数组(以及数组长度)
- django - 在django中创建帐户后无法登录