Skip to content

Commit b559d60

Browse files
authored
Merge pull request #61 from tddwizard/fixing-stuff
Final changes for 1.0.0 version
2 parents 3d32fe6 + 4dfaf53 commit b559d60

20 files changed

+60
-46
lines changed

.travis/before_script.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ composer config repositories.travis_to_test git https://github.com/$TRAVIS_REPO_
2828
if [ ! -z $TRAVIS_TAG ]
2929
then
3030
composer require ${COMPOSER_PACKAGE_NAME}:${TRAVIS_TAG}
31+
elif [ ! -z $TRAVIS_PULL_REQUEST_BRANCH ]
32+
then
33+
# For pull requests, use the remote repository
34+
composer config repositories.travis_to_test git https://github.com/${TRAVIS_PULL_REQUEST_SLUG}.git
35+
composer require ${COMPOSER_PACKAGE_NAME}:dev-${TRAVIS_PULL_REQUEST_BRANCH}\#${TRAVIS_PULL_REQUEST_SHA}
3136
else
3237
composer require ${COMPOSER_PACKAGE_NAME}:dev-${TRAVIS_BRANCH}\#${TRAVIS_COMMIT}
3338
fi

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
# TddWizard Fixture library
22

3-
This library is in *alpha* state, that means:
4-
5-
- it's super incomplete
6-
- nothing is guaranteed to work
7-
- everything can still be changed
8-
9-
103
[![Latest Version on Packagist][ico-version]][link-packagist]
114
[![Software License][ico-license]](LICENSE.md)
125
[![Build Status][ico-travis]][link-travis]
@@ -16,6 +9,10 @@ This library is in *alpha* state, that means:
169

1710
---
1811

12+
Magento 2 Fixtures by Fabian Schmengler
13+
14+
🧙🏻‍♂ https://tddwizard.com/
15+
1916
## What is it?
2017

2118
An alternative to the procedural script based fixtures in Magento 2 integration tests.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"magento/module-payment": "^100.3",
4343
"magento/module-quote": "^101.1",
4444
"magento/module-sales": "^102.0|^103.0",
45-
"fzaninotto/faker": "^v1.9.0"
45+
"fzaninotto/faker": "^1.8.0"
4646
},
4747
"require-dev": {
4848
"ext-json": "*",

src/Catalog/CategoryBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public static function childCategoryOf(
9999

100100
$category->setName('Child Category');
101101
$category->setIsActive(true);
102-
$category->setPath($parent->getCategory()->getPath());
102+
$category->setPath((string)$parent->getCategory()->getPath());
103103

104104
return new self(
105105
$objectManager->create(CategoryRepositoryInterface::class),

src/Catalog/CategoryFixture.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function getUrlKey(): string
3535
{
3636
/** @var Category $category */
3737
$category = $this->category;
38-
return $category->getUrlKey();
38+
return (string)$category->getUrlKey();
3939
}
4040

4141
public function rollback(): void

src/Catalog/CategoryFixturePool.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function get($key = null): CategoryFixture
3434
if ($key === null) {
3535
$key = \array_key_last($this->categoryFixtures);
3636
}
37-
if (!array_key_exists($key, $this->categoryFixtures)) {
37+
if ($key === null || !array_key_exists($key, $this->categoryFixtures)) {
3838
throw new \OutOfBoundsException('No matching category found in fixture pool');
3939
}
4040
return $this->categoryFixtures[$key];

src/Catalog/ProductBuilder.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ public static function aSimpleProduct(): ProductBuilder
144144
);
145145
}
146146

147+
public static function aVirtualProduct(): ProductBuilder
148+
{
149+
$builder = self::aSimpleProduct();
150+
$builder->product->setName('Virtual Product');
151+
$builder->product->setTypeId(Type::TYPE_VIRTUAL);
152+
return $builder;
153+
}
154+
147155
/**
148156
* @param mixed[] $data
149157
* @return ProductBuilder
@@ -346,12 +354,4 @@ private static function isTransactionException($exception): bool
346354
$exception->getMessage()
347355
);
348356
}
349-
350-
public static function aVirtualProduct(): ProductBuilder
351-
{
352-
$builder = self::aSimpleProduct();
353-
$builder->product->setName('Virtual Product');
354-
$builder->product->setTypeId(Type::TYPE_VIRTUAL);
355-
return $builder;
356-
}
357357
}

src/Catalog/ProductFixturePool.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function get($key = null): ProductFixture
3434
if ($key === null) {
3535
$key = \array_key_last($this->productFixtures);
3636
}
37-
if (!array_key_exists($key, $this->productFixtures)) {
37+
if ($key === null || !array_key_exists($key, $this->productFixtures)) {
3838
throw new \OutOfBoundsException('No matching product found in fixture pool');
3939
}
4040
return $this->productFixtures[$key];

src/Checkout/CustomerCheckout.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Magento\Quote\Api\CartRepositoryInterface;
1010
use Magento\Quote\Model\Quote;
1111
use Magento\Quote\Model\QuoteManagement;
12-
use Magento\Sales\Api\Data\OrderInterface;
12+
use Magento\Sales\Model\Order;
1313
use Magento\TestFramework\Helper\Bootstrap;
1414

1515
class CustomerCheckout
@@ -158,10 +158,10 @@ private function getPaymentMethodCode(): string
158158
}
159159

160160
/**
161-
* @return OrderInterface
161+
* @return Order
162162
* @throws \Exception
163163
*/
164-
public function placeOrder(): OrderInterface
164+
public function placeOrder(): Order
165165
{
166166
$this->saveBilling();
167167
$this->saveShipping();
@@ -171,6 +171,10 @@ public function placeOrder(): OrderInterface
171171
// Collect missing totals, like shipping
172172
$reloadedQuote->collectTotals();
173173
$order = $this->quoteManagement->submit($reloadedQuote);
174+
if (! $order instanceof Order) {
175+
$returnType = is_object($order) ? get_class($order) : gettype($order);
176+
throw new \RuntimeException('QuoteManagement::submit() returned ' . $returnType . ' instead of Order');
177+
}
174178
$this->cart->getCheckoutSession()->clearQuote();
175179
return $order;
176180
}

src/Customer/CustomerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ function (AddressBuilder $addressBuilder) {
208208
* Magento automatically sets random confirmation key for new account with password.
209209
* We need to save again with our own confirmation (null for confirmed customer)
210210
*/
211-
$customer->setConfirmation($builder->customer->getConfirmation());
211+
$customer->setConfirmation((string)$builder->customer->getConfirmation());
212212
return $builder->customerRepository->save($customer);
213213
}
214214

0 commit comments

Comments
 (0)