diff --git a/.gitignore b/.gitignore index eb5524487..c65faa2ef 100644 --- a/.gitignore +++ b/.gitignore @@ -74,3 +74,4 @@ npm-debug.log # tools composer.phar +c3.php diff --git a/c3.php b/c3.php deleted file mode 100644 index 4946e2249..000000000 --- a/c3.php +++ /dev/null @@ -1,280 +0,0 @@ - $value) { - $_SERVER["HTTP_X_CODECEPTION_" . strtoupper($key)] = $value; - } - } -} - -if (!array_key_exists('HTTP_X_CODECEPTION_CODECOVERAGE', $_SERVER)) { - return; -} - -if (!function_exists('__c3_error')) { - function __c3_error($message) - { - $errorLogFile = defined('C3_CODECOVERAGE_ERROR_LOG_FILE') ? - C3_CODECOVERAGE_ERROR_LOG_FILE : - C3_CODECOVERAGE_MEDIATE_STORAGE . DIRECTORY_SEPARATOR . 'error.txt'; - if (is_writable($errorLogFile)) { - file_put_contents($errorLogFile, $message); - } else { - $message = "Could not write error to log file ($errorLogFile), original message: $message"; - } - if (!headers_sent()) { - header('X-Codeception-CodeCoverage-Error: ' . str_replace("\n", ' ', $message), true, 500); - } - setcookie('CODECEPTION_CODECOVERAGE_ERROR', $message); - } -} - -// phpunit codecoverage shimming -if (class_exists('SebastianBergmann\CodeCoverage\CodeCoverage')) { - class_alias('SebastianBergmann\CodeCoverage\CodeCoverage', 'PHP_CodeCoverage'); - class_alias('SebastianBergmann\CodeCoverage\Report\Text', 'PHP_CodeCoverage_Report_Text'); - class_alias('SebastianBergmann\CodeCoverage\Report\PHP', 'PHP_CodeCoverage_Report_PHP'); - class_alias('SebastianBergmann\CodeCoverage\Report\Clover', 'PHP_CodeCoverage_Report_Clover'); - class_alias('SebastianBergmann\CodeCoverage\Report\Html\Facade', 'PHP_CodeCoverage_Report_HTML'); - class_alias('SebastianBergmann\CodeCoverage\Exception', 'PHP_CodeCoverage_Exception'); -} - -// Autoload Codeception classes -if (!class_exists('\\Codeception\\Codecept')) { - if (file_exists(__DIR__ . '/codecept.phar')) { - require_once 'phar://' . __DIR__ . '/codecept.phar/autoload.php'; - } elseif (stream_resolve_include_path(__DIR__ . '/vendor/autoload.php')) { - require_once __DIR__ . '/vendor/autoload.php'; - // Required to load some methods only available at codeception/autoload.php - if (stream_resolve_include_path(__DIR__ . '/vendor/codeception/codeception/autoload.php')) { - require_once __DIR__ . '/vendor/codeception/codeception/autoload.php'; - } - } elseif (stream_resolve_include_path('Codeception/autoload.php')) { - require_once 'Codeception/autoload.php'; - } else { - __c3_error('Codeception is not loaded. Please check that either PHAR or Composer package can be used'); - } -} - -// Load Codeception Config -$config_dist_file = realpath(__DIR__) . DIRECTORY_SEPARATOR . 'codeception.dist.yml'; -$config_file = realpath(__DIR__) . DIRECTORY_SEPARATOR . 'codeception.yml'; - -if (isset($_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_CONFIG'])) { - $config_file = realpath(__DIR__) . DIRECTORY_SEPARATOR . $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_CONFIG']; -} -if (file_exists($config_file)) { - // Use codeception.yml for configuration. -} elseif (file_exists($config_dist_file)) { - // Use codeception.dist.yml for configuration. - $config_file = $config_dist_file; -} else { - __c3_error(sprintf("Codeception config file '%s' not found", $config_file)); -} -try { - \Codeception\Configuration::config($config_file); -} catch (\Exception $e) { - __c3_error($e->getMessage()); -} - -if (!defined('C3_CODECOVERAGE_MEDIATE_STORAGE')) { - - // workaround for 'zend_mm_heap corrupted' problem - gc_disable(); - - $memoryLimit = ini_get('memory_limit'); - $requiredMemory = '384M'; - if ((substr($memoryLimit, -1) === 'M' && (int)$memoryLimit < (int)$requiredMemory) - || (substr($memoryLimit, -1) === 'K' && (int)$memoryLimit < (int)$requiredMemory * 1024) - || (ctype_digit($memoryLimit) && (int)$memoryLimit < (int)$requiredMemory * 1024 * 1024) - ) { - ini_set('memory_limit', $requiredMemory); - } - - define('C3_CODECOVERAGE_MEDIATE_STORAGE', Codeception\Configuration::logDir() . 'c3tmp'); - define('C3_CODECOVERAGE_PROJECT_ROOT', Codeception\Configuration::projectDir()); - define('C3_CODECOVERAGE_TESTNAME', $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE']); - - function __c3_build_html_report(PHP_CodeCoverage $codeCoverage, $path) - { - $writer = new PHP_CodeCoverage_Report_HTML(); - $writer->process($codeCoverage, $path . 'html'); - - if (file_exists($path . '.tar')) { - unlink($path . '.tar'); - } - - $phar = new PharData($path . '.tar'); - $phar->setSignatureAlgorithm(Phar::SHA1); - $files = $phar->buildFromDirectory($path . 'html'); - array_map('unlink', $files); - - if (in_array('GZ', Phar::getSupportedCompression())) { - if (file_exists($path . '.tar.gz')) { - unlink($path . '.tar.gz'); - } - - $phar->compress(\Phar::GZ); - - // close the file so that we can rename it - unset($phar); - - unlink($path . '.tar'); - rename($path . '.tar.gz', $path . '.tar'); - } - - return $path . '.tar'; - } - - function __c3_build_clover_report(PHP_CodeCoverage $codeCoverage, $path) - { - $writer = new PHP_CodeCoverage_Report_Clover(); - $writer->process($codeCoverage, $path . '.clover.xml'); - - return $path . '.clover.xml'; - } - - function __c3_send_file($filename) - { - if (!headers_sent()) { - readfile($filename); - } - - return __c3_exit(); - } - - /** - * @param $filename - * @return null|PHP_CodeCoverage - */ - function __c3_factory($filename) - { - $phpCoverage = is_readable($filename) - ? unserialize(file_get_contents($filename)) - : new PHP_CodeCoverage(); - - - if (isset($_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_SUITE'])) { - $suite = $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_SUITE']; - try { - $settings = \Codeception\Configuration::suiteSettings($suite, \Codeception\Configuration::config()); - } catch (Exception $e) { - __c3_error($e->getMessage()); - } - } else { - $settings = \Codeception\Configuration::config(); - } - - try { - \Codeception\Coverage\Filter::setup($phpCoverage) - ->whiteList($settings) - ->blackList($settings); - } catch (Exception $e) { - __c3_error($e->getMessage()); - } - - return $phpCoverage; - } - - function __c3_exit() - { - if (!isset($_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_DEBUG'])) { - exit; - } - return null; - } - - function __c3_clear() - { - \Codeception\Util\FileSystem::doEmptyDir(C3_CODECOVERAGE_MEDIATE_STORAGE); - } -} - -if (!is_dir(C3_CODECOVERAGE_MEDIATE_STORAGE)) { - if (mkdir(C3_CODECOVERAGE_MEDIATE_STORAGE, 0777, true) === false) { - __c3_error('Failed to create directory "' . C3_CODECOVERAGE_MEDIATE_STORAGE . '"'); - } -} - -// evaluate base path for c3-related files -$path = realpath(C3_CODECOVERAGE_MEDIATE_STORAGE) . DIRECTORY_SEPARATOR . 'codecoverage'; - -$requested_c3_report = (strpos($_SERVER['REQUEST_URI'], 'c3/report') !== false); - -$complete_report = $current_report = $path . '.serialized'; -if ($requested_c3_report) { - set_time_limit(0); - - $route = ltrim(strrchr($_SERVER['REQUEST_URI'], '/'), '/'); - - if ($route == 'clear') { - __c3_clear(); - return __c3_exit(); - } - - $codeCoverage = __c3_factory($complete_report); - - switch ($route) { - case 'html': - try { - __c3_send_file(__c3_build_html_report($codeCoverage, $path)); - } catch (Exception $e) { - __c3_error($e->getMessage()); - } - return __c3_exit(); - case 'clover': - try { - __c3_send_file(__c3_build_clover_report($codeCoverage, $path)); - } catch (Exception $e) { - __c3_error($e->getMessage()); - } - return __c3_exit(); - case 'serialized': - try { - __c3_send_file($complete_report); - } catch (Exception $e) { - __c3_error($e->getMessage()); - } - return __c3_exit(); - } - -} else { - $codeCoverage = __c3_factory($current_report); - $codeCoverage->start(C3_CODECOVERAGE_TESTNAME); - if (!array_key_exists('HTTP_X_CODECEPTION_CODECOVERAGE_DEBUG', $_SERVER)) { - register_shutdown_function( - function () use ($codeCoverage, $current_report) { - - $codeCoverage->stop(); - if (!file_exists(dirname($current_report))) { // verify directory exists - if (!mkdir(dirname($current_report), 0777, true)) { - __c3_error("Can't write CodeCoverage report into $current_report"); - } - } - - file_put_contents($current_report, serialize($codeCoverage)); - } - ); - } -} - -// @codeCoverageIgnoreEnd diff --git a/codeception.yml b/codeception.yml index 4246db75c..8c7b61d40 100644 --- a/codeception.yml +++ b/codeception.yml @@ -26,7 +26,7 @@ coverage: enabled: true remote: true c3_url: 'http://zed.de.spryker.dev' - whitelist: { include: ['src/*.php'] } + whitelist: { include: ['src/Pyz/*.php'] } extensions: enabled: diff --git a/config/Zed/StateMachine/Test/Invoice01.xml b/config/Zed/StateMachine/Test/Invoice01.xml index 89f767abf..802a1ab78 100644 --- a/config/Zed/StateMachine/Test/Invoice01.xml +++ b/config/Zed/StateMachine/Test/Invoice01.xml @@ -1,10 +1,12 @@ - + + xsi:schemaLocation="spryker:state-machine http://static.spryker.com/state-machine-01.xsd"> + + @@ -127,6 +129,7 @@ item not returned + diff --git a/config/Zed/navigation.xml b/config/Zed/navigation.xml index 699465cc8..f7a770343 100644 --- a/config/Zed/navigation.xml +++ b/config/Zed/navigation.xml @@ -1,4 +1,4 @@ - + diff --git a/config/Zed/oms/Nopayment01.xml b/config/Zed/oms/Nopayment01.xml index a80f201a2..8f57e2584 100644 --- a/config/Zed/oms/Nopayment01.xml +++ b/config/Zed/oms/Nopayment01.xml @@ -1,10 +1,12 @@ - + + xmlns="spryker:oms" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="spryker:oms http://static.spryker.com/oms-01.xsd"> + + @@ -71,11 +73,9 @@ returned return - - @@ -83,8 +83,8 @@ - + diff --git a/src/Pyz/Shared/Customer/Transfer/customer.transfer.xml b/src/Pyz/Shared/Customer/Transfer/customer.transfer.xml index 9b49aacc2..7c524b976 100644 --- a/src/Pyz/Shared/Customer/Transfer/customer.transfer.xml +++ b/src/Pyz/Shared/Customer/Transfer/customer.transfer.xml @@ -1,7 +1,7 @@ - + xsi:schemaLocation="spryker:transfer http://static.spryker.com/transfer-01.xsd" > diff --git a/src/Pyz/Shared/Sales/Transfer/sales.transfer.xml b/src/Pyz/Shared/Sales/Transfer/sales.transfer.xml index 15e62c5c7..b6c330472 100644 --- a/src/Pyz/Shared/Sales/Transfer/sales.transfer.xml +++ b/src/Pyz/Shared/Sales/Transfer/sales.transfer.xml @@ -1,7 +1,7 @@ - + xsi:schemaLocation="spryker:transfer http://static.spryker.com/transfer-01.xsd" > diff --git a/src/Pyz/Shared/Search/Transfer/search.transfer.xml b/src/Pyz/Shared/Search/Transfer/search.transfer.xml index 285e98200..d5ff47bb9 100644 --- a/src/Pyz/Shared/Search/Transfer/search.transfer.xml +++ b/src/Pyz/Shared/Search/Transfer/search.transfer.xml @@ -1,9 +1,10 @@ - + xsi:schemaLocation="spryker:transfer http://static.spryker.com/transfer-01.xsd" > + diff --git a/src/Pyz/Zed/Customer/Persistence/Propel/Schema/spy_customer.schema.xml b/src/Pyz/Zed/Customer/Persistence/Propel/Schema/spy_customer.schema.xml index 31357b075..0b3a4841f 100644 --- a/src/Pyz/Zed/Customer/Persistence/Propel/Schema/spy_customer.schema.xml +++ b/src/Pyz/Zed/Customer/Persistence/Propel/Schema/spy_customer.schema.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Pyz/Zed/StateMachineExample/Persistence/Propel/Schema/spy_state_machine_example.schema.xml b/src/Pyz/Zed/StateMachineExample/Persistence/Propel/Schema/spy_state_machine_example.schema.xml index 1a9b80cde..ee88e5f74 100644 --- a/src/Pyz/Zed/StateMachineExample/Persistence/Propel/Schema/spy_state_machine_example.schema.xml +++ b/src/Pyz/Zed/StateMachineExample/Persistence/Propel/Schema/spy_state_machine_example.schema.xml @@ -1,5 +1,5 @@ - +
diff --git a/tests/YvesUnit/Pyz/Yves/Assets/Communication/Model/AssetUrlBuilderTest.php b/tests/YvesUnit/Pyz/Yves/Assets/Communication/Model/AssetUrlBuilderTest.php index 0d001d0be..134b41ac0 100644 --- a/tests/YvesUnit/Pyz/Yves/Assets/Communication/Model/AssetUrlBuilderTest.php +++ b/tests/YvesUnit/Pyz/Yves/Assets/Communication/Model/AssetUrlBuilderTest.php @@ -71,7 +71,7 @@ public function testMediaUrlWithTrailingSlashes() */ private function getCacheBusterMock() { - $mock = $this->getMock(CacheBusterInterface::class); + $mock = $this->getMockBuilder(CacheBusterInterface::class)->getMock(); $mock->expects($this->any()) ->method('addCacheBust') ->will($this->returnArgument(0)); diff --git a/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/AddressStepTest.php b/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/AddressStepTest.php index f515e6731..c1a64f560 100644 --- a/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/AddressStepTest.php +++ b/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/AddressStepTest.php @@ -184,7 +184,11 @@ protected function createAddressStep($customerClientMock = null) $customerClientMock = $this->createCustomerClientMock(); } - $addressStepMock = $this->getMock(AddressStep::class, ['getDataClass'], [$customerClientMock, 'address_step', 'escape_route']); + $addressStepMock = $this->getMockBuilder(AddressStep::class) + ->setMethods(['getDataClass']) + ->setConstructorArgs([$customerClientMock, 'address_step', 'escape_route']) + ->getMock(); + $addressStepMock->method('getDataClass')->willReturn(new QuoteTransfer()); return $addressStepMock; @@ -203,7 +207,7 @@ protected function createRequest() */ protected function createCustomerClientMock() { - return $this->getMock(CustomerClientInterface::class); + return $this->getMockBuilder(CustomerClientInterface::class)->getMock(); } } diff --git a/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/CustomerStepTest.php b/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/CustomerStepTest.php index 8f4df38c1..4ceb42938 100644 --- a/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/CustomerStepTest.php +++ b/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/CustomerStepTest.php @@ -139,7 +139,7 @@ protected function createCustomerStep($customerClientMock = null, $authHandlerMo */ protected function createAuthHandlerMock() { - return $this->getMock(StepHandlerPluginInterface::class); + return $this->getMockBuilder(StepHandlerPluginInterface::class)->getMock(); } /** @@ -155,7 +155,7 @@ protected function createRequest() */ protected function createCustomerClientMock() { - return $this->getMock(CustomerClientInterface::class); + return $this->getMockBuilder(CustomerClientInterface::class)->getMock(); } } diff --git a/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/PaymentStepTest.php b/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/PaymentStepTest.php index 8bb090c6e..2c8cb47cc 100644 --- a/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/PaymentStepTest.php +++ b/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/PaymentStepTest.php @@ -99,7 +99,7 @@ protected function createRequest() */ protected function createPaymentPluginMock() { - return $this->getMock(StepHandlerPluginInterface::class); + return $this->getMockBuilder(StepHandlerPluginInterface::class)->getMock(); } /** @@ -107,7 +107,7 @@ protected function createPaymentPluginMock() */ protected function getFlashMessengerMock() { - return $this->getMock(FlashMessengerInterface::class); + return $this->getMockBuilder(FlashMessengerInterface::class)->getMock(); } } diff --git a/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/PlaceOrderStepTest.php b/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/PlaceOrderStepTest.php index 302c339be..622882e8c 100644 --- a/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/PlaceOrderStepTest.php +++ b/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/PlaceOrderStepTest.php @@ -152,7 +152,7 @@ protected function createRequest() */ protected function createFlashMessengerMock() { - return $this->getMock(FlashMessengerInterface::class); + return $this->getMockBuilder(FlashMessengerInterface::class)->getMock(); } /** @@ -160,7 +160,7 @@ protected function createFlashMessengerMock() */ protected function createCheckoutClientMock() { - return $this->getMock(CheckoutClientInterface::class); + return $this->getMockBuilder(CheckoutClientInterface::class)->getMock(); } /** @@ -168,7 +168,7 @@ protected function createCheckoutClientMock() */ protected function createShipmentMock() { - return $this->getMock(StepHandlerPluginInterface::class); + return $this->getMockBuilder(StepHandlerPluginInterface::class)->getMock(); } } diff --git a/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/ShipmentStepTest.php b/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/ShipmentStepTest.php index cfead1d75..f7cf05d41 100644 --- a/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/ShipmentStepTest.php +++ b/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/ShipmentStepTest.php @@ -102,7 +102,7 @@ protected function createRequest() */ protected function createCalculationClientMock() { - $calculationMock = $this->getMock(CalculationClientInterface::class); + $calculationMock = $this->getMockBuilder(CalculationClientInterface::class)->getMock(); $calculationMock->method('recalculate')->willReturnArgument(0); return $calculationMock; @@ -113,7 +113,7 @@ protected function createCalculationClientMock() */ protected function createShipmentMock() { - return $this->getMock(StepHandlerPluginInterface::class); + return $this->getMockBuilder(StepHandlerPluginInterface::class)->getMock(); } } diff --git a/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/SuccessStepTest.php b/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/SuccessStepTest.php index 805cfb1d0..8bd31d2ee 100644 --- a/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/SuccessStepTest.php +++ b/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/SuccessStepTest.php @@ -98,7 +98,7 @@ protected function createRequest() */ protected function createCustomerClientMock() { - return $this->getMock(CustomerClientInterface::class); + return $this->getMockBuilder(CustomerClientInterface::class)->getMock(); } } diff --git a/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/SummaryStepTest.php b/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/SummaryStepTest.php index 07e5e2878..80aca319c 100644 --- a/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/SummaryStepTest.php +++ b/tests/YvesUnit/Pyz/Yves/Checkout/Process/Steps/SummaryStepTest.php @@ -97,7 +97,7 @@ protected function createRequest() */ protected function createCalculationClientMock() { - return $this->getMock(CalculationClientInterface::class); + return $this->getMockBuilder(CalculationClientInterface::class)->getMock(); } /** @@ -105,7 +105,7 @@ protected function createCalculationClientMock() */ protected function createShipmentMock() { - return $this->getMock(StepHandlerPluginInterface::class); + return $this->getMockBuilder(StepHandlerPluginInterface::class)->getMock(); } }