Skip to content
This repository has been archived by the owner on Feb 4, 2019. It is now read-only.

Commit

Permalink
core-1652 replaced slow Presentation with an example of a fast functi…
Browse files Browse the repository at this point in the history
…onal Controller test
  • Loading branch information
stereomon committed Aug 3, 2017
1 parent d53dd92 commit b1bb1cc
Show file tree
Hide file tree
Showing 11 changed files with 263 additions and 3,081 deletions.
2 changes: 1 addition & 1 deletion codeception.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ actor: Tester

include:
- tests/PyzTest/*/*
- vendor/spryker/spryker/Bundles/*/*
# - vendor/spryker/spryker/Bundles/*/*

paths:
tests: tests
Expand Down
6 changes: 3 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config/Shared/config_default-devtest_DE.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
$config[ApplicationConstants::YVES_TRUSTED_HOSTS] = [
$config[ApplicationConstants::HOST_YVES],
$config[ApplicationConstants::HOST_ZED],
'localhost',
];

// ---------- Propel
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
<?php

/**
* This file is part of the Spryker Demoshop.
* For full license information, please view the LICENSE file that was distributed with this source code.
*/

namespace PyzTest\Shared\Testify\Helper\Bootstrap;

use Pyz\Shared\Application\Business\Routing\SilexRouter;
use Pyz\Shared\Application\Plugin\Provider\WebProfilerServiceProvider;
use Pyz\Yves\Application\Plugin\Provider\ApplicationControllerProvider;
use Pyz\Yves\Application\Plugin\Provider\ApplicationServiceProvider;
use Pyz\Yves\Application\Plugin\Provider\AutoloaderCacheServiceProvider;
use Pyz\Yves\Application\Plugin\Provider\LanguageServiceProvider;
use Pyz\Yves\Application\Plugin\Provider\YvesSecurityServiceProvider;
use Pyz\Yves\Calculation\Plugin\Provider\CalculationControllerProvider;
use Pyz\Yves\Cart\Plugin\Provider\CartControllerProvider;
use Pyz\Yves\Cart\Plugin\Provider\CartServiceProvider;
use Pyz\Yves\Catalog\Plugin\Provider\CatalogControllerProvider;
use Pyz\Yves\Category\Plugin\Provider\CategoryServiceProvider;
use Pyz\Yves\Checkout\Plugin\Provider\CheckoutControllerProvider;
use Pyz\Yves\Collector\Plugin\Router\StorageRouter;
use Pyz\Yves\Customer\Plugin\Provider\CustomerControllerProvider;
use Pyz\Yves\Customer\Plugin\Provider\CustomerSecurityServiceProvider;
use Pyz\Yves\Glossary\Plugin\Provider\TranslationServiceProvider;
use Pyz\Yves\Heartbeat\Plugin\Provider\HeartbeatControllerProvider;
use Pyz\Yves\Newsletter\Plugin\Provider\NewsletterControllerProvider;
use Pyz\Yves\ProductNew\Plugin\Provider\ProductNewControllerProvider;
use Pyz\Yves\ProductSale\Plugin\Provider\ProductSaleControllerProvider;
use Pyz\Yves\ProductSet\Plugin\Provider\ProductSetControllerProvider;
use Pyz\Yves\Twig\Plugin\Provider\TwigServiceProvider;
use Pyz\Yves\Wishlist\Plugin\Provider\WishlistControllerProvider;
use Silex\Provider\FormServiceProvider;
use Silex\Provider\HttpFragmentServiceProvider;
use Silex\Provider\RememberMeServiceProvider;
use Silex\Provider\SecurityServiceProvider;
use Silex\Provider\ServiceControllerServiceProvider;
use Silex\Provider\SessionServiceProvider;
use Silex\Provider\ValidatorServiceProvider;
use Spryker\Shared\Application\ApplicationConstants;
use Spryker\Shared\Application\ServiceProvider\FormFactoryServiceProvider;
use Spryker\Shared\Application\ServiceProvider\HeadersSecurityServiceProvider;
use Spryker\Shared\Application\ServiceProvider\RoutingServiceProvider;
use Spryker\Shared\Application\ServiceProvider\UrlGeneratorServiceProvider;
use Spryker\Shared\Config\Config;
use Spryker\Yves\Application\Plugin\Provider\CookieServiceProvider;
use Spryker\Yves\Application\Plugin\Provider\ExceptionServiceProvider;
use Spryker\Yves\Application\Plugin\Provider\YvesHstsServiceProvider;
use Spryker\Yves\CmsContentWidget\Plugin\CmsContentWidgetServiceProvider;
use Spryker\Yves\Kernel\Application;
use Spryker\Yves\Messenger\Plugin\Provider\FlashMessengerServiceProvider;
use Spryker\Yves\Money\Plugin\ServiceProvider\TwigMoneyServiceProvider;
use Spryker\Yves\Navigation\Plugin\Provider\NavigationTwigServiceProvider;
use Spryker\Yves\NewRelic\Plugin\ServiceProvider\NewRelicRequestTransactionServiceProvider;
use Spryker\Yves\ProductGroup\Plugin\Provider\ProductGroupTwigServiceProvider;
use Spryker\Yves\ProductLabel\Plugin\Provider\ProductLabelTwigServiceProvider;
use Spryker\Yves\ProductRelation\Plugin\ProductRelationTwigServiceProvider;
use Spryker\Yves\Session\Plugin\ServiceProvider\SessionServiceProvider as SprykerSessionServiceProvider;
use Spryker\Yves\Storage\Plugin\Provider\StorageCacheServiceProvider;
use Spryker\Yves\Twig\Plugin\ServiceProvider\TwigServiceProvider as SprykerTwigServiceProvider;

class YvesBootstrap
{

/**
* @var \Spryker\Yves\Kernel\Application
*/
protected $application;

public function __construct()
{
$this->application = new Application();
}

/**
* @return \Spryker\Yves\Kernel\Application
*/
public function boot()
{
$this->registerServiceProviders();

$this->registerRouters();

$this->registerControllerProviders();

return $this->application;
}

/**
* @return void
*/
protected function registerServiceProviders()
{
$this->application->register(new StorageCacheServiceProvider());
$this->application->register(new SprykerTwigServiceProvider());
$this->application->register(new TwigServiceProvider());
$this->application->register(new ApplicationServiceProvider());
$this->application->register(new SessionServiceProvider());
$this->application->register(new SprykerSessionServiceProvider());
$this->application->register(new SecurityServiceProvider());
$this->application->register(new CustomerSecurityServiceProvider());
$this->application->register(new YvesSecurityServiceProvider());
$this->application->register(new ExceptionServiceProvider());
$this->application->register(new NewRelicRequestTransactionServiceProvider());
$this->application->register(new CookieServiceProvider());
$this->application->register(new UrlGeneratorServiceProvider());
$this->application->register(new ServiceControllerServiceProvider());
$this->application->register(new RememberMeServiceProvider());
$this->application->register(new RoutingServiceProvider());
$this->application->register(new TranslationServiceProvider());
$this->application->register(new ValidatorServiceProvider());
$this->application->register(new FormServiceProvider());
$this->application->register(new HttpFragmentServiceProvider());
$this->application->register(new CategoryServiceProvider());
$this->application->register(new FlashMessengerServiceProvider());
$this->application->register(new HeadersSecurityServiceProvider());
$this->application->register(new WebProfilerServiceProvider());
$this->application->register(new AutoloaderCacheServiceProvider());
$this->application->register(new YvesHstsServiceProvider());
$this->application->register(new CartServiceProvider());
$this->application->register(new FormFactoryServiceProvider());
$this->application->register(new LanguageServiceProvider());
$this->application->register(new TwigMoneyServiceProvider());
$this->application->register(new ProductRelationTwigServiceProvider());
$this->application->register(new NavigationTwigServiceProvider());
$this->application->register(new ProductGroupTwigServiceProvider());
$this->application->register(new ProductLabelTwigServiceProvider());
$this->application->register(new CmsContentWidgetServiceProvider());
}

/**
* @return void
*/
protected function registerRouters()
{
$this->application->addRouter((new StorageRouter())->setSsl(false));
$this->application->addRouter(new SilexRouter($this->application));
}

/**
* @return void
*/
protected function registerControllerProviders()
{
$isSsl = Config::get(ApplicationConstants::YVES_SSL_ENABLED);

$controllerProviders = $this->getControllerProviderStack($isSsl);

foreach ($controllerProviders as $controllerProvider) {
$this->application->mount($controllerProvider->getUrlPrefix(), $controllerProvider);
}
}

/**
* @param bool|null $isSsl
*
* @return \Pyz\Yves\Application\Plugin\Provider\AbstractYvesControllerProvider[]
*/
protected function getControllerProviderStack($isSsl)
{
return [
new ApplicationControllerProvider($isSsl),
new CheckoutControllerProvider($isSsl),
new CustomerControllerProvider($isSsl),
new CartControllerProvider($isSsl),
new WishlistControllerProvider($isSsl),
new HeartbeatControllerProvider($isSsl),
new NewsletterControllerProvider($isSsl),
new CatalogControllerProvider($isSsl),
new CalculationControllerProvider($isSsl),
new ProductSetControllerProvider($isSsl),
new ProductSaleControllerProvider($isSsl),
new ProductNewControllerProvider($isSsl),
];
}

}
56 changes: 56 additions & 0 deletions tests/PyzTest/Shared/Testify/_support/Helper/YvesBootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?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 PyzTest\Shared\Testify\Helper;

use Codeception\Exception\ModuleConfigException;
use Codeception\Lib\Framework;
use Codeception\TestInterface;
use PyzTest\Shared\Testify\Helper\Bootstrap\YvesBootstrap as ApplicationYvesBootstrap;
use Symfony\Component\HttpKernel\Client;

class YvesBootstrap extends Framework
{

/**
* @var \Spryker\Zed\Testify\Bootstrap\ZedBootstrap
*/
private $application;

/**
* @return void
*/
public function _initialize()
{
$this->loadApplication();
}

/**
* @param \Codeception\TestInterface $test
*
* @return void
*/
public function _before(TestInterface $test)
{
$this->client = new Client($this->application->boot());
}

/**
* @throws \Codeception\Exception\ModuleConfigException
*
* @return void
*/
protected function loadApplication()
{
$this->application = new ApplicationYvesBootstrap();

if (!isset($this->application)) {
throw new ModuleConfigException(__CLASS__, 'Application instance was not received from bootstrap file');
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,30 @@
* For full license information, please view the LICENSE file that was distributed with this source code.
*/

namespace PyzTest\Yves\Application\Presentation;
namespace PyzTest\Yves\Application\Communication\Controller;

use PyzTest\Yves\Application\ApplicationPresentationTester;
use PyzTest\Yves\Application\ApplicationCommunicationTester;
use PyzTest\Yves\Application\PageObject\Homepage;

/**
* Auto-generated group annotations
* @group PyzTest
* @group Yves
* @group Application
* @group Presentation
* @group Communication
* @group Controller
* @group HomepageCest
* Add your own group annotations below this line
*/
class HomepageCest
{

/**
* @param \PyzTest\Yves\Application\ApplicationPresentationTester $i
* @param \PyzTest\Yves\Application\ApplicationCommunicationTester $i
*
* @return void
*/
public function testICanOpenHomepage(ApplicationPresentationTester $i)
public function testICanOpenHomepage(ApplicationCommunicationTester $i)
{
$i->wantTo('See that i can open the homepage');
$i->amOnPage(Homepage::URL);
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[INFO - 2017-08-03T13:17:58.677Z] GhostDriver - Main - running on port 4444
[INFO - 2017-08-03T13:56:18.713Z] GhostDriver - Main - running on port 4444
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
namespace PyzTest\Yves\Application;

use Codeception\Actor;
use Codeception\Scenario;

/**
* Inherited Methods
Expand All @@ -19,19 +18,13 @@
*
* @SuppressWarnings(PHPMD)
*/
class ApplicationPresentationTester extends Actor
class ApplicationCommunicationTester extends Actor
{

use _generated\ApplicationPresentationTesterActions;
use _generated\ApplicationCommunicationTesterActions;

/**
* @param \Codeception\Scenario $scenario
*/
public function __construct(Scenario $scenario)
{
parent::__construct($scenario);

$this->amYves();
}
/**
* Define custom actions here
*/

}
Loading

0 comments on commit b1bb1cc

Please sign in to comment.