Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit 7611315

Browse files
author
Jens Schulze
authored
feat(ShippingMethod): support shipping rate tiers (#384)
Closes #355 * WIP: shipping rate tiers * WIP: shipping rate tiers * fix travis build * chore: update development tool versions * chore: fix travis build * WIP: add project update test * WIP: add tests for shipping method price tiers * WIP: fix test * WIP: shipping rate tiers * test(RAML): fix raml model tests * chore(Travis): execute integration test only for push commits * chore(Travis): execute integration test only for push commits * chore(Composer): remove unneeded dev dependencies * test(Raml): one assert for valid field check per class * test(Fixtures): remove unneeded classes from fixtures which are covered by RAML * test(Fixtures): remove unneeded classes from generic action test which are covered by RAML * WIP: fix score type for ScoreShippingRateInput
1 parent 30dd044 commit 7611315

File tree

56 files changed

+1499
-1915
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1499
-1915
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ script:
3636
- ant phpcs-ci
3737
- if [ $GUZZLE == '5' ] || [ $PHP == '5.6' ] || [ $PHP == 'hhvm' ] ; then vendor/bin/phpunit -c phpunit5.xml.dist --testsuite=unit; fi
3838
- if [ $GUZZLE == '6' ] && [ $PHP != '5.6' ] ; then vendor/bin/phpunit --testsuite=unit; fi
39-
- if [ $PHP == '7.0' ] && [ $GUZZLE == '6' ] ; then vendor/bin/phpunit --testsuite=integration; fi
39+
- if [ $PHP == '7.0' ] && [ $GUZZLE == '6' ] && [ $TRAVIS_PULL_REQUEST == 'false' ]; then vendor/bin/phpunit --testsuite=integration; fi
4040
- ant behat
4141
after_success:
4242
- if [ $PHP == '7.1' ] && [ $GUZZLE == '6' ] ; then ./push-docs-to-gh-pages.sh; fi

build.xml

Lines changed: 1 addition & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<!-- <property name="toolsdir" value="${basedir}/vendor/bin/"/> -->
1212

1313
<target name="build"
14-
depends="prepare,lint,phploc-ci,pdepend,phpmd-ci,phpcs-ci,phpcpd-ci,unit-test,apigen"
14+
depends="prepare,lint,phpcs-ci,unit-test,apigen"
1515
description=""/>
1616

1717
<target name="build-parallel"
@@ -20,13 +20,7 @@
2020

2121
<target name="tools-parallel" description="Run tools in parallel">
2222
<parallel threadCount="2">
23-
<sequential>
24-
<antcall target="pdepend"/>
25-
<antcall target="phpmd-ci"/>
26-
</sequential>
27-
<antcall target="phpcpd-ci"/>
2823
<antcall target="phpcs-ci"/>
29-
<antcall target="phploc-ci"/>
3024
</parallel>
3125
</target>
3226

@@ -36,7 +30,6 @@
3630
<delete dir="${basedir}/build/docs"/>
3731
<delete dir="${basedir}/build/coverage"/>
3832
<delete dir="${basedir}/build/logs"/>
39-
<delete dir="${basedir}/build/pdepend"/>
4033
<property name="clean.done" value="true"/>
4134
</target>
4235

@@ -47,7 +40,6 @@
4740
<mkdir dir="${basedir}/build/docs"/>
4841
<mkdir dir="${basedir}/build/coverage"/>
4942
<mkdir dir="${basedir}/build/logs"/>
50-
<mkdir dir="${basedir}/build/pdepend"/>
5143
<property name="prepare.done" value="true"/>
5244
</target>
5345

@@ -67,63 +59,6 @@
6759
</apply>
6860
</target>
6961

70-
<target name="phploc"
71-
description="Measure project size using PHPLOC and print human readable output. Intended for usage on the command line.">
72-
<exec executable="${toolsdir}phploc${execPostfix}">
73-
<arg value="--count-tests" />
74-
<arg path="${basedir}/src" />
75-
<arg path="${basedir}/tests" />
76-
</exec>
77-
</target>
78-
79-
<target name="phploc-ci"
80-
depends="prepare"
81-
description="Measure project size using PHPLOC and log result in CSV and XML format. Intended for usage within a continuous integration environment.">
82-
<exec executable="${toolsdir}phploc${execPostfix}">
83-
<arg value="--count-tests" />
84-
<arg value="--log-csv" />
85-
<arg path="${basedir}/build/logs/phploc.csv" />
86-
<arg value="--log-xml" />
87-
<arg path="${basedir}/build/logs/phploc.xml" />
88-
<arg path="${basedir}/src" />
89-
<arg path="${basedir}/tests" />
90-
</exec>
91-
</target>
92-
93-
<target name="pdepend"
94-
depends="prepare"
95-
description="Calculate software metrics using PHP_Depend and log result in XML format. Intended for usage within a continuous integration environment.">
96-
<exec executable="${toolsdir}pdepend${execPostfix}">
97-
<arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
98-
<arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
99-
<arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
100-
<arg path="${basedir}/src" />
101-
</exec>
102-
</target>
103-
104-
<target name="phpmd"
105-
description="Perform project mess detection using PHPMD and print human readable output. Intended for usage on the command line before committing.">
106-
<exec executable="${toolsdir}phpmd${execPostfix}">
107-
<arg path="${basedir}/src" />
108-
<arg value="text" />
109-
<arg value="codesize,controversial,design,naming,unusedcode"/>
110-
<arg path="${basedir}/build/phpmd.xml" />
111-
</exec>
112-
</target>
113-
114-
<target name="phpmd-ci"
115-
depends="prepare"
116-
description="Perform project mess detection using PHPMD and log result in XML format. Intended for usage within a continuous integration environment.">
117-
<exec executable="${toolsdir}phpmd${execPostfix}">
118-
<arg path="${basedir}/src" />
119-
<arg value="xml" />
120-
<arg value="codesize,controversial,design,naming,unusedcode"/>
121-
<arg path="${basedir}/build/phpmd.xml" />
122-
<arg value="--reportfile" />
123-
<arg path="${basedir}/build/logs/pmd.xml" />
124-
</exec>
125-
</target>
126-
12762
<target name="phpcs"
12863
description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
12964
<exec executable="${toolsdir}phpcs${execPostfix}" failonerror="true">
@@ -146,23 +81,6 @@
14681
</exec>
14782
</target>
14883

149-
<target name="phpcpd"
150-
description="Find duplicate code using PHPCPD and print human readable output. Intended for usage on the command line before committing.">
151-
<exec executable="${toolsdir}phpcpd${execPostfix}">
152-
<arg path="${basedir}/src" />
153-
</exec>
154-
</target>
155-
156-
<target name="phpcpd-ci"
157-
depends="prepare"
158-
description="Find duplicate code using PHPCPD and log result in XML format. Intended for usage within a continuous integration environment.">
159-
<exec executable="${toolsdir}phpcpd${execPostfix}">
160-
<arg value="--log-pmd" />
161-
<arg path="${basedir}/build/logs/pmd-cpd.xml" />
162-
<arg path="${basedir}/src" />
163-
</exec>
164-
</target>
165-
16684
<target name="behat"
16785
depends="prepare"
16886
description="Run behat tests"

composer.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,13 @@
4141
"require-dev": {
4242
"guzzlehttp/guzzle": "^6.0",
4343
"phpunit/phpunit": "^6.0 || ^5.7.21",
44-
"phpmd/phpmd": "@stable",
45-
"squizlabs/php_codesniffer": "^2.6",
46-
"sebastian/phpcpd": "@stable",
47-
"pdepend/pdepend": "@stable",
48-
"phploc/phploc": "^2.0",
49-
"mayflower/php-codebrowser": "^1.0",
44+
"squizlabs/php_codesniffer": "^3.2",
5045
"doctrine/cache": "^1.6",
5146
"monolog/monolog": "^1.12",
5247
"behat/behat": "^3.0",
53-
"phpunit/phpcov": "*",
54-
"friendsofphp/php-cs-fixer": "@stable",
5548
"symfony/yaml": "^3.2",
5649
"cache/adapter-common": "^1.0",
50+
"cache/apcu-adapter": "^1.0",
5751
"cache/array-adapter": "^1.0",
5852
"cache/doctrine-adapter": "^1.0",
5953
"cache/redis-adapter": "^1.0",

src/Core/Model/Cart/Cart.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
* @method Cart setOrigin(string $origin = null)
7676
* @method string getTaxCalculationMode()
7777
* @method Cart setTaxCalculationMode(string $taxCalculationMode = null)
78+
* @method ShippingRateInput getShippingRateInput()
79+
* @method Cart setShippingRateInput(ShippingRateInput $shippingRateInput = null)
7880
* @method CartReference getReference()
7981
*/
8082
class Cart extends Resource
@@ -132,6 +134,7 @@ public function fieldDefinitions()
132134
'refusedGifts' => [static::TYPE => CartDiscountReferenceCollection::class],
133135
'origin' => [static::TYPE => 'string'],
134136
'taxCalculationMode' => [static::TYPE => 'string'],
137+
'shippingRateInput' => [static::TYPE => ShippingRateInput::class]
135138
];
136139
}
137140

src/Core/Model/Cart/CartDraft.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
* @method CartDraft setTaxCalculationMode(string $taxCalculationMode = null)
5757
* @method ExternalTaxRateDraft getExternalTaxRateForShippingMethod()
5858
* @method CartDraft setExternalTaxRateForShippingMethod(ExternalTaxRateDraft $externalTaxRateForShippingMethod = null)
59+
* @method ShippingRateInputDraft getShippingRateInput()
60+
* @method CartDraft setShippingRateInput(ShippingRateInputDraft $shippingRateInput = null)
5961
*/
6062
class CartDraft extends JsonObject
6163
{
@@ -83,7 +85,8 @@ public function fieldDefinitions()
8385
'customerGroup' => [static::TYPE => CustomerGroupReference::class],
8486
'origin' => [static::TYPE => 'string'],
8587
'taxCalculationMode' => [static::TYPE => 'string'],
86-
'externalTaxRateForShippingMethod' => [static::TYPE => ExternalTaxRateDraft::class]
88+
'externalTaxRateForShippingMethod' => [static::TYPE => ExternalTaxRateDraft::class],
89+
'shippingRateInput' => [static::TYPE => ShippingRateInputDraft::class],
8790
];
8891
}
8992

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* @author @jayS-de <jens.schulze@commercetools.de>
4+
* @created: 27.01.15, 18:22
5+
*/
6+
7+
namespace Commercetools\Core\Model\Cart;
8+
9+
use Commercetools\Core\Model\Common\Context;
10+
use Commercetools\Core\Model\Common\LocalizedString;
11+
12+
/**
13+
* @package Commercetools\Core\Model\Cart
14+
* @link http://dev.commercetools.com/http-api-projects-carts.html#classificationshippingrateinput
15+
* @method string getType()
16+
* @method ClassificationShippingRateInput setType(string $type = null)
17+
* @method string getKey()
18+
* @method ClassificationShippingRateInput setKey(string $key = null)
19+
* @method LocalizedString getLabel()
20+
* @method ClassificationShippingRateInput setLabel(LocalizedString $label = null)
21+
*/
22+
class ClassificationShippingRateInput extends ShippingRateInput
23+
{
24+
const INPUT_TYPE = 'Classification';
25+
26+
public function fieldDefinitions()
27+
{
28+
return [
29+
'type' => [static::TYPE => 'string'],
30+
'key' => [static::TYPE => 'string'],
31+
'label' => [static::TYPE => LocalizedString::class]
32+
];
33+
}
34+
35+
/**
36+
* @param $key
37+
* @param $label
38+
* @param Context|callable $context
39+
* @return ClassificationShippingRateInput
40+
*/
41+
public static function ofKeyAndLabel($key, $label, $context = null)
42+
{
43+
return static::ofType(static::INPUT_TYPE, $context)->setKey($key)->setLabel($label);
44+
}
45+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* @author @jayS-de <jens.schulze@commercetools.de>
4+
* @created: 27.01.15, 18:22
5+
*/
6+
7+
namespace Commercetools\Core\Model\Cart;
8+
9+
use Commercetools\Core\Model\Common\Context;
10+
use Commercetools\Core\Model\Common\LocalizedString;
11+
12+
/**
13+
* @package Commercetools\Core\Model\Cart
14+
* @link http://dev.commercetools.com/http-api-projects-carts.html#classificationshippingrateinputdraft
15+
* @method string getType()
16+
* @method ClassificationShippingRateInputDraft setType(string $type = null)
17+
* @method string getKey()
18+
* @method ClassificationShippingRateInputDraft setKey(string $key = null)
19+
* @method LocalizedString getLabel()
20+
* @method ClassificationShippingRateInputDraft setLabel(LocalizedString $label = null)
21+
*/
22+
class ClassificationShippingRateInputDraft extends ShippingRateInputDraft
23+
{
24+
public function fieldDefinitions()
25+
{
26+
return [
27+
'type' => [static::TYPE => 'string'],
28+
'key' => [static::TYPE => 'string'],
29+
];
30+
}
31+
32+
/**
33+
* @param $key
34+
* @param $label
35+
* @param Context|callable $context
36+
* @return ClassificationShippingRateInputDraft
37+
*/
38+
public static function ofKeyAndLabel($key, $label, $context = null)
39+
{
40+
return static::ofType(ClassificationShippingRateInput::INPUT_TYPE, $context)
41+
->setKey($key)
42+
->setLabel($label);
43+
}
44+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* @author @jayS-de <jens.schulze@commercetools.de>
4+
* @created: 27.01.15, 18:22
5+
*/
6+
7+
namespace Commercetools\Core\Model\Cart;
8+
9+
use Commercetools\Core\Model\Common\Context;
10+
11+
/**
12+
* @package Commercetools\Core\Model\Cart
13+
* @link http://dev.commercetools.com/http-api-projects-carts.html#scoreshippingrateinput
14+
* @method string getType()
15+
* @method ScoreShippingRateInput setType(string $type = null)
16+
* @method int getScore()
17+
* @method ScoreShippingRateInput setScore(int $score = null)
18+
*/
19+
class ScoreShippingRateInput extends ShippingRateInput
20+
{
21+
const INPUT_TYPE = 'Score';
22+
23+
public function fieldDefinitions()
24+
{
25+
return [
26+
'type' => [static::TYPE => 'string'],
27+
'score' => [static::TYPE => 'int'],
28+
];
29+
}
30+
31+
/**
32+
* @param int $score
33+
* @param Context|callable $context
34+
* @return ScoreShippingRateInput
35+
*/
36+
public static function ofScore($score, $context = null)
37+
{
38+
return static::ofType(static::INPUT_TYPE, $context)->setScore($score);
39+
}
40+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* @author @jayS-de <jens.schulze@commercetools.de>
4+
* @created: 27.01.15, 18:22
5+
*/
6+
7+
namespace Commercetools\Core\Model\Cart;
8+
9+
use Commercetools\Core\Model\Common\Context;
10+
11+
/**
12+
* @package Commercetools\Core\Model\Cart
13+
* @link http://dev.commercetools.com/http-api-projects-carts.html#scoreshippingrateinputdraft
14+
* @method string getType()
15+
* @method ScoreShippingRateInputDraft setType(string $type = null)
16+
* @method int getScore()
17+
* @method ScoreShippingRateInputDraft setScore(int $score = null)
18+
*/
19+
class ScoreShippingRateInputDraft extends ShippingRateInputDraft
20+
{
21+
public function fieldDefinitions()
22+
{
23+
return [
24+
'type' => [static::TYPE => 'string'],
25+
'score' => [static::TYPE => 'int'],
26+
];
27+
}
28+
29+
/**
30+
* @param int $score
31+
* @param Context|callable $context
32+
* @return ScoreShippingRateInputDraft
33+
*/
34+
public static function ofScore($score, $context = null)
35+
{
36+
return static::ofType(ScoreShippingRateInput::INPUT_TYPE, $context)->setScore($score);
37+
}
38+
}

0 commit comments

Comments
 (0)