Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
createRepositoryMock example
->
setInvalidValue
(
'Bar'
)
->
setCause
(
[
$entity1
]
)
->
setCode
(
UniqueEntity::NOT_UNIQUE_ERROR
)
->
assertRaised
(
)
;
}
/** * @dataProvider provideConstraintsWithCustomRepositoryMethod */
public
function
testValidateUniquenessUsingCustomRepositoryMethod
(
UniqueEntity
$constraint
)
{
$repository
=
$this
->
createRepositoryMock
(
)
;
$repository
->
expects
(
$this
->
once
(
)
)
->
method
(
'findByCustom'
)
->
willReturn
(
[
]
)
;
$this
->em =
$this
->
createEntityManagerMock
(
$repository
)
;
$this
->registry =
$this
->
createRegistryMock
(
$this
->em
)
;
$this
->validator =
$this
->
createValidator
(
)
;
$this
->validator->
initialize
(
$this
->context
)
;
$entity1
=
new
SingleIntIdEntity
(
1, 'foo'
)
;