Passed
Pull Request — master (#579)
by Dima
08:13
created

PriceProductScheduleApplyConsole   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 25
c 1
b 0
f 0
dl 0
loc 45
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 37 1
1
<?php
2
3
/**
4
 * This file is part of the Spryker Commerce OS.
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
declare(strict_types = 1);
9
10
namespace Pyz\Zed\PriceProductSchedule\Communication\Console;
11
12
use Generated\Shared\Transfer\StockConditionsTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\StockConditionsTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Generated\Shared\Transfer\StockCriteriaTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\StockCriteriaTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Generated\Shared\Transfer\UserConditionsTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\UserConditionsTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Generated\Shared\Transfer\UserCriteriaTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\UserCriteriaTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use Generated\Shared\Transfer\WarehouseUserAssignmentCollectionRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...llectionRequestTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Generated\Shared\Transfer\WarehouseUserAssignmentTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...eUserAssignmentTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use Spryker\Zed\PriceProductSchedule\Communication\Console\PriceProductScheduleApplyConsole as SprykerPriceProductScheduleApplyConsole;
19
use Spryker\Zed\Stock\Business\StockFacade;
20
use Spryker\Zed\User\Business\UserFacade;
21
use Spryker\Zed\WarehouseUser\Business\WarehouseUserFacade;
22
use Symfony\Component\Console\Input\InputInterface;
23
use Symfony\Component\Console\Output\OutputInterface;
24
25
/**
26
 * @method \Spryker\Zed\PriceProductSchedule\Persistence\PriceProductScheduleRepositoryInterface getRepository()
27
 * @method \Spryker\Zed\PriceProductSchedule\Business\PriceProductScheduleFacadeInterface getFacade()
28
 */
29
class PriceProductScheduleApplyConsole extends SprykerPriceProductScheduleApplyConsole
30
{
31
    /**
32
     * @param \Symfony\Component\Console\Input\InputInterface $input
33
     * @param \Symfony\Component\Console\Output\OutputInterface $output
34
     *
35
     * @return int
36
     */
37
    protected function execute(InputInterface $input, OutputInterface $output): int
38
    {
39
        // For E2E tests purpose only, should not be used in production.
40
        $userTransfer = (new UserFacade())->getUserCollection(
41
            (new UserCriteriaTransfer())->setUserConditions(
42
                (new UserConditionsTransfer())
43
                    ->addUsername('[email protected]'),
44
            ),
45
        )->getUsers()->getIterator()->current();
46
47
        /** @var list<\Generated\Shared\Transfer\StockTransfer> $stockTransfers */
48
        $stockTransfers = (new StockFacade())->getStockCollection(
49
            (new StockCriteriaTransfer())->setStockConditions(
50
                (new StockConditionsTransfer())
51
                    ->addStockName('Warehouse1')
52
                    ->addStockName('Spryker MER000001 Warehouse 1'),
53
            ),
54
        )->getStocks()->getArrayCopy();
55
56
        $warehouseUserAssignmentCollectionRequestTransfer = (new WarehouseUserAssignmentCollectionRequestTransfer())
57
            ->addWarehouseUserAssignment(
58
                (new WarehouseUserAssignmentTransfer())
59
                    ->setUserUuid($userTransfer->getUuid())
60
                    ->setWarehouse($stockTransfers[0]),
61
            )
62
            ->addWarehouseUserAssignment(
63
                (new WarehouseUserAssignmentTransfer())
64
                    ->setUserUuid($userTransfer->getUuid())
65
                    ->setWarehouse($stockTransfers[1]),
66
            );
67
68
        (new WarehouseUserFacade())
69
            ->createWarehouseUserAssignmentCollection(
70
                $warehouseUserAssignmentCollectionRequestTransfer,
71
            );
72
73
        return parent::execute($input, $output);
74
    }
75
}
76