Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicWatts committed Aug 24, 2021
2 parents c0df7be + 7df8f9f commit 3d76deb
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 11 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/phpcsfixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: php-cs-fixer
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: PHP CS Fixer
run: docker run --rm -v $PWD:/code domw/php-cs-fixer php-cs-fixer fix --dry-run --diff --stop-on-violation --allow-risky=yes ./
39 changes: 39 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

/**
* PHP Coding Standards fixer configuration
*/

$finder = PhpCsFixer\Finder::create()
->in('Console')
->in('Helper')
->name('*.phtml');

$config = new PhpCsFixer\Config();
$config->setFinder($finder)
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one'],
'include' => true,
'new_with_braces' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'multiline_whitespace_before_semicolons' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_unused_imports' => true,
'no_whitespace_in_blank_line' => true,
'object_operator_without_whitespace' => true,
'ordered_imports' => true,
'standardize_not_equals' => true,
'ternary_operator_spaces' => true,
]);
return $config;
3 changes: 3 additions & 0 deletions Console/Command/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function __construct(

/**
* {@inheritdoc}
* @return int
*/
protected function execute(
InputInterface $input,
Expand Down Expand Up @@ -138,7 +139,9 @@ protected function execute(
$progress->finish();
$this->output->writeln('');
$this->output->writeln('[' . $this->dateTime->gmtDate() . '] Finish');
return Cli::RETURN_SUCCESS;
}
return Cli::RETURN_FAILURE;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions Console/Command/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public function __construct(

/**
* {@inheritdoc}
* @return int
*/
protected function execute(
InputInterface $input,
Expand Down Expand Up @@ -141,7 +142,9 @@ protected function execute(
$progress->finish();
$this->output->writeln('');
$this->output->writeln('[' . $this->dateTime->gmtDate() . '] Finish');
return Cli::RETURN_SUCCESS;
}
return Cli::RETURN_FAILURE;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions Console/Command/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public function __construct(

/**
* {@inheritdoc}
* @return int
*/
protected function execute(
InputInterface $input,
Expand Down Expand Up @@ -140,7 +141,9 @@ protected function execute(
$progress->finish();
$this->output->writeln('');
$this->output->writeln('[' . $this->dateTime->gmtDate() . '] Finish');
return Cli::RETURN_SUCCESS;
}
return Cli::RETURN_FAILURE;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions Console/Command/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public function __construct(

/**
* {@inheritdoc}
* @return int
*/
protected function execute(
InputInterface $input,
Expand Down Expand Up @@ -150,7 +151,9 @@ protected function execute(
$progress->finish();
$this->output->writeln('');
$this->output->writeln('[' . $this->dateTime->gmtDate() . '] Finish');
return Cli::RETURN_SUCCESS;
}
return Cli::RETURN_FAILURE;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions Console/Command/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function __construct(

/**
* {@inheritdoc}
* @return int
*/
protected function execute(
InputInterface $input,
Expand Down Expand Up @@ -139,7 +140,9 @@ protected function execute(
$progress->finish();
$this->output->writeln('');
$this->output->writeln('[' . $this->dateTime->gmtDate() . '] Finish');
return Cli::RETURN_SUCCESS;
}
return Cli::RETURN_FAILURE;
}

/**
Expand Down
6 changes: 4 additions & 2 deletions Helper/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function __construct(
/**
* Create random customer
* @param int $websiteId
* @return \Magento\Customer\Api\Data\CustomerInterface
* @return \Magento\Customer\Api\Data\CustomerInterface|false
*/
public function createCustomer($websiteId = 1)
{
Expand All @@ -120,13 +120,14 @@ public function createCustomer($websiteId = 1)
return $customer;
} catch (\Exception $e) {
$this->logger->critical($e);
return false;
}
}

/**
* Create address for supplied customerId.
* @param \Magento\Customer\Model\Data\Customer $customer
* @return \Magento\Customer\Api\Data\AddressInterface
* @return \Magento\Customer\Api\Data\AddressInterface|false
*/
public function createCustomerAddress(\Magento\Customer\Model\Data\Customer $customer)
{
Expand All @@ -152,6 +153,7 @@ public function createCustomerAddress(\Magento\Customer\Model\Data\Customer $cus
return $address;
} catch (\Exception $e) {
$this->logger->critical($e);
return false;
}
}
}
Expand Down
8 changes: 3 additions & 5 deletions Helper/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function createOrder($storeId = 1, $customerId = null)

try {
$store = $this->storeManagerInterface->getStore($storeId);

$websiteId = $store->getWebsiteId();

if ($customerId) {
Expand Down Expand Up @@ -185,7 +185,6 @@ public function createOrder($storeId = 1, $customerId = null)

$added = 0;
foreach ($productIds as $productId) {

$product = $this->getProductById($productId);
if ($product->isSalable()) {
$qty = $this->stockItem->getStockQty($product->getId(), $websiteId);
Expand Down Expand Up @@ -218,15 +217,14 @@ public function createOrder($storeId = 1, $customerId = null)

$quote->collectTotals();
$quote = $this->cartRepositoryInterface->get($quote->getId());

$orderId = $this->cartManagementInterface->placeOrder($quote->getId());
$this->generateInvoice($orderId);
if ($this->getRandomTrueOrFalse()) {
$this->generateShipment($orderId, $this->getRandomTrueOrFalse());
}

return $orderId;

} catch (\Exception $e) {
$this->logger->critical($e);
return $e->getMessage();
Expand Down Expand Up @@ -279,7 +277,7 @@ public function generateShipment($orderId, $doNotify = true)
if (!$order || !$order->canShip()) {
return;
}

$orderShipment = $this->convertOrder->toShipment($order);

foreach ($order->getAllItems() as $orderItem) {
Expand Down
6 changes: 4 additions & 2 deletions Helper/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function __construct(
* @param int $websiteId
* @param string $typeId
* @param bool $applyImage
* @return \Magento\Catalog\Model\Product\Interceptor
* @return \Magento\Catalog\Model\Product\Interceptor|false
*/
public function createProduct(
$websiteId = 1,
Expand Down Expand Up @@ -205,13 +205,14 @@ public function createProduct(
return $product;
} catch (\Exception $e) {
$this->logger->critical($e);
return false;
}
}

/**
* Reload product [might not actually need this].
* @param $product
* @return \Magento\Product\Model\Data\Product
* @return \Magento\Product\Model\Data\Product|false
*/
public function reloadProduct(Interceptor $product)
{
Expand All @@ -222,6 +223,7 @@ public function reloadProduct(Interceptor $product)
return $product;
} catch (\Exception $e) {
$this->logger->critical($e);
return false;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Console based fake data generator - just generate what you need",
"type": "magento2-module",
"license": "proprietary",
"version": "1.2.0",
"version": "1.2.1",
"authors": [
{
"name": "Dominic Xigen",
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Xigen_Faker" setup_version="1.2.0"/>
<module name="Xigen_Faker" setup_version="1.2.1"/>
</config>

0 comments on commit 3d76deb

Please sign in to comment.