Skip to content

Commit

Permalink
TE-10139 PHPStan 1.0 upgrade (#2095)
Browse files Browse the repository at this point in the history
TE-10139 PHPStan 1.0 integration
  • Loading branch information
dimitriyTsemma authored Dec 15, 2021
1 parent 5c8de8f commit a85b9f8
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 4 deletions.
16 changes: 16 additions & 0 deletions codeception.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace: QuickOrderPage
include:
- tests/QuickOrderPageTest/Yves/QuickOrderPage
paths:
tests: tests
log: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
settings:
suite_class: \PHPUnit\Framework\TestSuite
colors: true
memory_limit: 1024M
log: true
coverage:
enabled: true
14 changes: 11 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
},
"require-dev": {
"spryker/code-sniffer": "*",
"spryker/product": "*",
"spryker/propel": "*",
"spryker/router": "*",
"spryker/silex": "*"
"spryker/silex": "*",
"spryker/testify": "*"
},
"suggest": {
"spryker-shop/cart-page": "Widget plugins are available for this module.",
Expand All @@ -36,11 +39,16 @@
"SprykerShop\\": "src/SprykerShop/"
}
},
"autoload-dev": {
"psr-4": {
"SprykerShopTest\\": "tests/SprykerShopTest/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"cs-check": "phpcs -p -s --standard=vendor/spryker/code-sniffer/Spryker/ruleset.xml src/",
"cs-fix": "phpcbf -p --standard=vendor/spryker/code-sniffer/Spryker/ruleset.xml src/"
"cs-check": "phpcs -p -s --standard=vendor/spryker/code-sniffer/Spryker/ruleset.xml src/ tests/",
"cs-fix": "phpcbf -p --standard=vendor/spryker/code-sniffer/Spryker/ruleset.xml src/ tests/"
},
"extra": {
"branch-alias": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ protected function getDataByPath(ProductConcreteTransfer $productConcreteTransfe
$data = array_reduce(
$path,
function ($object, $property) {
return is_object($property) ? $object->{$property} : $object[$property];
$propertyGetter = sprintf('get%s', ucfirst($property));

return is_object($object) ? $object->{$propertyGetter}() : $object[$property];
},
$productConcreteTransfer,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

/**
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
*/

namespace SprykerShopTest\Yves\QuickOrderPage\Business;

use Codeception\Test\Unit;
use Generated\Shared\Transfer\ProductMeasurementUnitTransfer;
use SprykerShop\Yves\QuickOrderPage\ViewDataTransformer\ViewDataTransformer;
use SprykerShop\Yves\QuickOrderPageExtension\Dependency\Plugin\QuickOrderFormColumnPluginInterface;

/**
* @group SprykerShop
* @group Yves
* @group QuickOrderPage
* @group Business
* @group ViewDataTransformerTest
*/
class ViewDataTransformerTest extends Unit
{
/**
* @var string
*/
protected const PATH = 'baseMeasurementUnit.name';

/**
* @var string
*/
protected const PRODUCT_MEASUREMENT_UNIT_NAME = 'Name';

/**
* @var \QuickOrderPageTest\Yves\QuickOrderPage\QuickOrderPageTester
*/
protected $tester;

/**
* @return void
*/
public function testTransformProductData(): void
{
// Arrange
$productConcreteTransfer = $this->tester->haveProduct();
$productConcreteTransfer->setBaseMeasurementUnit((new ProductMeasurementUnitTransfer())->setName(static::PRODUCT_MEASUREMENT_UNIT_NAME));
// Act
$getDataByPath = (new ViewDataTransformer())->transformProductData([$productConcreteTransfer], [$this->getQuickOrderFormColumnPluginMock()]);

// Assert
$this->assertIsArray($getDataByPath);
$this->assertIsArray($getDataByPath[$productConcreteTransfer->getSku()]);
$this->assertIsArray($getDataByPath[$productConcreteTransfer->getSku()]['columns']);
$this->assertEquals($productConcreteTransfer->getSku(), $getDataByPath[$productConcreteTransfer->getSku()]['sku']);
$this->assertEquals($productConcreteTransfer->getName(), $getDataByPath[$productConcreteTransfer->getSku()]['name']);
$this->assertEquals(static::PATH, array_key_first($getDataByPath[$productConcreteTransfer->getSku()]['columns']));
$this->assertEquals(static::PRODUCT_MEASUREMENT_UNIT_NAME, $getDataByPath[$productConcreteTransfer->getSku()]['columns'][static::PATH]);
}

/**
* @return \PHPUnit\Framework\MockObject\MockObject|\SprykerShop\Yves\QuickOrderPageExtension\Dependency\Plugin\QuickOrderFormColumnPluginInterface
*/
protected function getQuickOrderFormColumnPluginMock(): QuickOrderFormColumnPluginInterface
{
$quickOrderFormColumnPluginMock = $this->getMockBuilder(QuickOrderFormColumnPluginInterface::class)->getMock();
$quickOrderFormColumnPluginMock->method('getDataPath')->willReturn(static::PATH);

return $quickOrderFormColumnPluginMock;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
*/

namespace SprykerShopTest\Yves\QuickOrderPage;

use Codeception\Actor;

/**
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method void pause()
*
* @SuppressWarnings(PHPMD)
*/
class QuickOrderPageTester extends Actor
{
use _generated\QuickOrderPageTesterActions;
}
24 changes: 24 additions & 0 deletions tests/SprykerShopTest/Yves/QuickOrderPage/codeception.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace: SprykerShopTest\Yves\QuickOrderPage
paths:
tests: .
data: ../../../_data
support: _support
log: ../../../_output
coverage:
enabled: true
remote: false
whitelist:
include:
- '../../../../src/*'
suites:
Yves:
path: .
class_name: QuickOrderPageTester
modules:
enabled:
- Asserts
- \SprykerTest\Shared\Testify\Helper\Environment
- \SprykerTest\Shared\Testify\Helper\LocatorHelper
- \SprykerTest\Shared\Propel\Helper\TransactionHelper
- \SprykerTest\Shared\Testify\Helper\DataCleanupHelper
- \SprykerTest\Shared\Product\Helper\ProductDataHelper

0 comments on commit a85b9f8

Please sign in to comment.