Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setTechnicalName example
$connection
=
$this
->
getConnectionMock
(
)
;
$connection
->
method
(
'createQueryBuilder'
)
->
willReturn
(
$queryBuilder
)
;
$stockUpdater
=
new
StockUpdater
(
$connection
,
$this
->dispatcher,
new
StockUpdateFilterProvider
(
[
$filter
]
)
,
)
;
$fromStateEntity
=
new
StateMachineStateEntity
(
)
;
$fromStateEntity
->
setTechnicalName
(
OrderStates::STATE_OPEN
)
;
$toStateEntity
=
new
StateMachineStateEntity
(
)
;
$toStateEntity
->
setTechnicalName
(
OrderStates::STATE_CANCELLED
)
;
$event
=
new
StateMachineTransitionEvent
(
OrderDefinition::ENTITY_NAME,
$this
->ids->
get
(
'order1'
)
,
$fromStateEntity
,
$toStateEntity
,
Context::
createDefaultContext
(
)
)
;
'state' =>
[
'quantity' => 15, 'referenced_id' => 'product-2'
]
,
]
,
]
,
]
;
}
public
function
testStateChangeCanBeDisabled
(
)
: void
{
$context
= Context::
createDefaultContext
(
)
->
createWithVersionId
(
$this
->ids->
create
(
'version'
)
)
;
$fromState
=
new
StateMachineStateEntity
(
)
;
$fromState
->
setTechnicalName
(
OrderStates::STATE_OPEN
)
;
$toState
=
new
StateMachineStateEntity
(
)
;
$toState
->
setTechnicalName
(
OrderStates::STATE_CANCELLED
)
;
$event
=
new
StateMachineTransitionEvent
(
OrderDefinition::ENTITY_NAME,
$this
->ids->
get
(
'order-1'
)
,
$fromState
,
$toState
,
$context
)
;
/** * @internal * * @covers \Shopware\Core\System\Tax\TaxRuleType\ZipCodeRangeRuleTypeFilter */
class
ZipCodeRangeRuleTypeFilterTest
extends
TestCase
{
public
function
testMatchesNotWithWrongType
(
)
: void
{
$type
=
new
TaxRuleTypeEntity
(
)
;
$type
->
setTechnicalName
(
'not me'
)
;
$rule
=
new
TaxRuleEntity
(
)
;
$rule
->
setActiveFrom
(
new
\
DateTime
(
'2020-01-01'
)
)
;
$rule
->
setType
(
$type
)
;
$filter
=
new
ZipCodeRangeRuleTypeFilter
(
)
;
static
::
assertFalse
(
$filter
->
match
(
$rule
, null,
new
ShippingLocation
(
new
CountryEntity
(
)
, null, null
)
)
)
;
}
public
function
testMatchesNotWithWithoutAddress
(
)
: void
{
$orderDeliveryCollection
->
add
(
$orderDelivery
)
;
}
// Transactions
$orderTransactionCollection
=
new
OrderTransactionCollection
(
)
;
$orderTransaction
=
new
OrderTransactionEntity
(
)
;
$orderTransaction
->
setId
(
'order-transaction-id'
)
;
$orderTransaction
->
setPaymentMethodId
(
'order-transaction-payment-method-id'
)
;
$stateMachineState
=
new
StateMachineStateEntity
(
)
;
$stateMachineState
->
setId
(
'state-machine-state-id'
)
;
$stateMachineState
->
setTechnicalName
(
'state-machine-state-technical-name'
)
;
$orderTransaction
->
setStateMachineState
(
$stateMachineState
)
;
$orderTransactionCancelled
=
new
OrderTransactionEntity
(
)
;
$orderTransactionCancelled
->
setId
(
'order-transaction-cancelled-id'
)
;
$orderTransactionCancelled
->
setPaymentMethodId
(
'order-transaction-cancelled-payment-method-id'
)
;
$stateMachineStateCancelled
=
new
StateMachineStateEntity
(
)
;
$stateMachineStateCancelled
->
setId
(
'state-machine-cancelled-state-id'
)
;
$stateMachineStateCancelled
->
setTechnicalName
(
'cancelled'
)
;
$orderTransactionCancelled
->
setStateMachineState
(
$stateMachineStateCancelled
)
;
$orderTransactionFailed
=
new
OrderTransactionEntity
(
)
;
$snippetFileCollection
->
add
(
$snippetFile
)
;
}
}
}
private
function
loadAppSnippets
(
SnippetFileCollection
$snippetFileCollection
)
: void
{
foreach
(
$this
->activeAppsLoader->
getActiveApps
(
)
as
$app
)
{
$snippetFiles
=
$this
->appSnippetFileLoader->
loadSnippetFilesFromApp
(
$app
[
'author'
]
?? '',
$app
[
'path'
]
)
;
foreach
(
$snippetFiles
as
$snippetFile
)
{
$snippetFile
->
setTechnicalName
(
$app
[
'name'
]
)
;
$snippetFileCollection
->
add
(
$snippetFile
)
;
}
}
}
/** * @return AbstractSnippetFile[] */
private
function
loadSnippetFilesInDir
(
string
$snippetDir
, Bundle
$bundle
)
: array
{
$finder
=
new
Finder
(
)
;
static
::
assertEquals
(
RuleConstraints::
uuidOperators
(
false
)
,
$constraints
[
'operator'
]
)
;
}
/** * @dataProvider getMatchingValues * * @param list<string> $selectedOrderStateIds */
public
function
testOrderPaymentStatusRuleMatching
(
bool
$expected
, string
$orderStateId
, array
$selectedOrderStateIds
, string
$operator
)
: void
{
$stateMachineState
=
new
StateMachineStateEntity
(
)
;
$stateMachineState
->
setTechnicalName
(
OrderTransactionStates::STATE_IN_PROGRESS
)
;
$orderTransactionCollection
=
new
OrderTransactionCollection
(
)
;
$orderTransaction
=
new
OrderTransactionEntity
(
)
;
$orderTransaction
->
setId
(
Uuid::
randomHex
(
)
)
;
$orderTransaction
->
setStateId
(
$orderStateId
)
;
$orderTransaction
->
setStateMachineState
(
$stateMachineState
)
;
$orderTransactionCollection
->
add
(
$orderTransaction
)
;
$order
=
new
OrderEntity
(
)
;
$order
->
setTransactions
(
$orderTransactionCollection
)
;
$cart
=
$this
->
createMock
(
Cart::
class
)
;
$context
=
$this
->
createMock
(
SalesChannelContext::
class
)
;
$licences
=
[
]
;
foreach
(
$data
as
$row
)
{
if
(
!
isset
(
$row
[
'plugin'
]
)
)
{
continue
;
}
$licence
=
new
LicenceStruct
(
)
;
$licence
->
setLabel
(
$row
[
'description'
]
)
;
$licence
->
setTechnicalName
(
$row
[
'plugin'
]
[
'name'
]
)
;
$licence
->
setShop
(
$row
[
'shop'
]
)
;
if
(
$row
[
'domain'
]
)
{
$licence
->
setShop
(
$row
[
'domain'
]
)
;
}
$licence
->
setIconPath
(
$row
[
'plugin'
]
[
'iconPath'
]
)
;
if
(
isset
(
$row
[
'creationDate'
]
)
)
{
$date
=
new
DateTime
(
$row
[
'creationDate'
]
)
;
$licence
->
setCreationDate
(
$date
)
;
}
/** * @internal * * @covers \Shopware\Core\System\Tax\TaxRuleType\ZipCodeRuleTypeFilter */
class
ZipCodeRuleTypeFilterTest
extends
TestCase
{
public
function
testMatchesNotWithWrongType
(
)
: void
{
$type
=
new
TaxRuleTypeEntity
(
)
;
$type
->
setTechnicalName
(
'not me'
)
;
$rule
=
new
TaxRuleEntity
(
)
;
$rule
->
setActiveFrom
(
new
\
DateTime
(
'2020-01-01'
)
)
;
$rule
->
setType
(
$type
)
;
$filter
=
new
ZipCodeRuleTypeFilter
(
)
;
static
::
assertFalse
(
$filter
->
match
(
$rule
, null,
new
ShippingLocation
(
new
CountryEntity
(
)
, null, null
)
)
)
;
}
public
function
testMatchesNotWithWithoutAddress
(
)
: void
{
/** * @internal * * @covers \Shopware\Core\System\Tax\TaxRuleType\IndividualStatesRuleTypeFilter */
class
IndividualStatesRuleTypeFilterTest
extends
TestCase
{
public
function
testMatchesNotWithWrongType
(
)
: void
{
$type
=
new
TaxRuleTypeEntity
(
)
;
$type
->
setTechnicalName
(
'not me'
)
;
$rule
=
new
TaxRuleEntity
(
)
;
$rule
->
setActiveFrom
(
new
\
DateTime
(
'2020-01-01'
)
)
;
$rule
->
setType
(
$type
)
;
$filter
=
new
IndividualStatesRuleTypeFilter
(
)
;
static
::
assertFalse
(
$filter
->
match
(
$rule
, null,
new
ShippingLocation
(
new
CountryEntity
(
)
, null, null
)
)
)
;
}
public
function
testMatchesNotWithWithoutState
(
)
: void
{
/** * @internal * * @covers \Shopware\Core\System\Tax\TaxRuleType\EntireCountryRuleTypeFilter */
class
EntireCountryRuleTypeFilterTest
extends
TestCase
{
public
function
testMatchesNotWithWrongType
(
)
: void
{
$type
=
new
TaxRuleTypeEntity
(
)
;
$type
->
setTechnicalName
(
'not me'
)
;
$rule
=
new
TaxRuleEntity
(
)
;
$rule
->
setActiveFrom
(
new
\
DateTime
(
'2020-01-01'
)
)
;
$rule
->
setType
(
$type
)
;
$filter
=
new
EntireCountryRuleTypeFilter
(
)
;
static
::
assertFalse
(
$filter
->
match
(
$rule
, null,
new
ShippingLocation
(
new
CountryEntity
(
)
, null, null
)
)
)
;
}
public
function
testMatchesNotWithWrongCountry
(
)
: void
{