Skip to content

Commit

Permalink
Merge pull request #1 from fond-of/bugfix/refactoring
Browse files Browse the repository at this point in the history
Bugfix/refactoring
  • Loading branch information
julianzimmermann authored Jan 3, 2020
2 parents 9c9348f + 1465d9b commit f892281
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ language: php
php:
- 7.1

env:
COMPOSER_MEMORY_LIMIT=-1

cache:
directories:
- vendor
Expand All @@ -16,4 +19,4 @@ script:
- vendor/bin/codecept run --coverage-xml

after_success:
- vendor/bin/php-coveralls
- vendor/bin/php-coveralls
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types=1);
declare(strict_types = 1);

namespace FondOfSpryker\Zed\Product\Business\Product\Sku;

Expand Down
10 changes: 10 additions & 0 deletions src/FondOfSpryker/Zed/Product/Business/ProductBusinessFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace FondOfSpryker\Zed\Product\Business;

use FondOfSpryker\Zed\Product\Business\Product\Sku\SkuGenerator;
use FondOfSpryker\Zed\Product\Dependency\Facade\ProductToUrlInterface;
use FondOfSpryker\Zed\Product\ProductDependencyProvider;
use Spryker\Zed\Product\Business\Product\ProductAbstractManager;
use Spryker\Zed\Product\Business\Product\Sku\SkuGeneratorInterface;
use Spryker\Zed\Product\Business\Product\Url\ProductUrlGeneratorInterface;
Expand Down Expand Up @@ -63,4 +65,12 @@ public function createSkuGenerator(): SkuGeneratorInterface
{
return new SkuGenerator($this->getUtilTextService(), $this->createSkuIncrementGenerator());
}

/**
* @return \FondOfSpryker\Zed\Product\Dependency\Facade\ProductToUrlInterface
*/
protected function getUrlFacade(): ProductToUrlInterface
{
return $this->getProvidedDependency(ProductDependencyProvider::FACADE_URL);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class UrlProductAbstractBeforeCreatePlugin extends AbstractPlugin implements Pro
/**
* @param \Generated\Shared\Transfer\ProductAbstractTransfer $productAbstractTransfer
*
* @throws \FondOfSpryker\Zed\Product\Business\Exception\DuplicateUrlKeyException
*
* @return \Generated\Shared\Transfer\ProductAbstractTransfer
*/
public function create(ProductAbstractTransfer $productAbstractTransfer): ProductAbstractTransfer
Expand Down
13 changes: 13 additions & 0 deletions src/FondOfSpryker/Zed/Product/ProductDependencyProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

class ProductDependencyProvider extends BaseProductDependencyProvider
{
public const FACADE_URL = 'FACADE_URL';

/**
* @param \Spryker\Zed\Kernel\Container $container
*
Expand All @@ -16,7 +18,18 @@ class ProductDependencyProvider extends BaseProductDependencyProvider
public function provideBusinessLayerDependencies(Container $container): Container
{
$container = parent::provideBusinessLayerDependencies($container);
$container = $this->addUrlFacade($container);

return $container;
}

/**
* @param \Spryker\Zed\Kernel\Container $container
*
* @return \Spryker\Zed\Kernel\Container
*/
protected function addUrlFacade(Container $container): Container
{
$container[self::FACADE_URL] = function (Container $container) {
return new ProductToUrlBridge($container->getLocator()->url()->facade());
};
Expand Down
1 change: 0 additions & 1 deletion tests/FondOfSpryker/Zed/Product/ProductConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ public function testGetUrlAttributeCode()

$this->assertEquals('url_key', $productConfig->getUrlAttributeCode());
}

}
23 changes: 18 additions & 5 deletions tests/_bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
<?php

use org\bovigo\vfs\vfsStream;
use Spryker\Shared\Config\Environment;

require_once __DIR__ . '/../vendor/autoload.php';
$pathToAutoloader = codecept_root_dir('vendor/autoload.php');

define('APPLICATION_ENV', Environment::TESTING);
define('APPLICATION_STORE', 'UNIT');
if (!file_exists($pathToAutoloader)) {
$pathToAutoloader = codecept_root_dir('../../autoload.php');
}

$stream = \org\bovigo\vfs\vfsStream::setup('root');
define('APPLICATION_ROOT_DIR', $stream->url());
require_once $pathToAutoloader;

if (!defined('APPLICATION_ENV')) {
define('APPLICATION_ENV', Environment::TESTING);
}
if (!defined('APPLICATION_STORE')) {
define('APPLICATION_STORE', 'UNIT');
}

if (!defined('APPLICATION_ROOT_DIR')) {
$stream = vfsStream::setup('root');
define('APPLICATION_ROOT_DIR', $stream->url());
}

0 comments on commit f892281

Please sign in to comment.