本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Exception\InvalidArgumentException::associationFormatExpected方法的典型用法代码示例。如果您正苦于以下问题:PHP InvalidArgumentException::associationFormatExpected方法的具体用法?PHP InvalidArgumentException::associationFormatExpected怎么用?PHP InvalidArgumentException::associationFormatExpected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\Exception\InvalidArgumentException
的用法示例。
在下文中一共展示了InvalidArgumentException::associationFormatExpected方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_checks_valid_association_data_format(ProductInterface $product)
{
$this->shouldThrow(InvalidArgumentException::arrayExpected('associations', 'setter', 'association', 'string'))->during('setFieldData', [$product, 'associations', 'not an array']);
$this->shouldThrow(InvalidArgumentException::associationFormatExpected('associations', [0 => []]))->during('setFieldData', [$product, 'associations', [0 => []]]);
$this->shouldThrow(InvalidArgumentException::associationFormatExpected('associations', ['assoc_type_code' => []]))->during('setFieldData', [$product, 'associations', ['assoc_type_code' => []]]);
$this->shouldThrow(InvalidArgumentException::associationFormatExpected('associations', ['assoc_type_code' => ['products' => [1], 'groups' => []]]))->during('setFieldData', [$product, 'associations', ['assoc_type_code' => ['products' => [1], 'groups' => []]]]);
$this->shouldThrow(InvalidArgumentException::associationFormatExpected('associations', ['assoc_type_code' => ['products' => [], 'groups' => [2]]]))->during('setFieldData', [$product, 'associations', ['assoc_type_code' => ['products' => [], 'groups' => [2]]]]);
}
示例2: checkAssociationItems
/**
* @param string $field
* @param array $data
* @param array $items
*
* @throws InvalidArgumentException
*/
protected function checkAssociationItems($field, array $data, array $items)
{
foreach ($items as $code) {
if (!is_string($code)) {
throw InvalidArgumentException::associationFormatExpected($field, $data);
}
}
}