Skip to content
Snippets Groups Projects
Commit b6c3ae8a authored by Vadim Justus's avatar Vadim Justus
Browse files

Fix integration tests and add coverage report

parent 65f5d51e
Branches
Tags
No related merge requests found
Pipeline #504 passed
......@@ -6,22 +6,27 @@ integration-ce-22-php72:
tags:
- php72
variables:
EXECUTOR_SUITE: module-integration-tests
EXECUTOR_SUITE: module-integration
MAGENTO_EDITION: community
MAGENTO_VERSION: 2.2.*
COVERAGE_REPORT: html
before_script:
- ~/.composer/vendor/met/test-executor/run.sh setup
script:
- DISPLAY_VARS="NO" ~/.composer/vendor/met/test-executor/run.sh tests
after_script:
- DISPLAY_VARS="NO" ~/.composer/vendor/met/test-executor/run.sh cleanup
artifacts:
paths:
- /tmp/reports/${CI_JOB_ID}
expire_in: 1 week
integration-ce-23-php73:
stage: test
tags:
- php73
variables:
EXECUTOR_SUITE: module-integration-tests
EXECUTOR_SUITE: module-integration
MAGENTO_EDITION: community
MAGENTO_VERSION: 2.3.*
before_script:
......
<?php
/**
* Copyright (c) 2019 TechDivision GmbH
* All rights reserved
*
* This product includes proprietary software developed at TechDivision GmbH, Germany
* For more information see http://www.techdivision.com/
*
* To obtain a valid license for using this software please contact us at
* license@techdivision.com
*/
declare(strict_types=1);
namespace Met\ExampleMagento2ModuleTesting\Model;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
/**
* @copyright Copyright (c) 2019 TechDivision GmbH (http://www.techdivision.com)
* @link http://www.techdivision.com/
* @author Vadim Justus <v.justus@techdivision.com>
*/
class Example
{
/**
* @var SearchCriteriaBuilder
*/
private $searchCriteriaBuilder;
/**
* @var OrderRepositoryInterface
*/
private $orderRepository;
/**
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param OrderRepositoryInterface $orderRepository
*/
public function __construct(
SearchCriteriaBuilder $searchCriteriaBuilder,
OrderRepositoryInterface $orderRepository
) {
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->orderRepository = $orderRepository;
}
/**
* @return OrderInterface[]
*/
public function execute(): array
{
$searchCriteria = $this->searchCriteriaBuilder
->addFilter(OrderInterface::INCREMENT_ID, 'MET%', 'like')
->create();
return $this->orderRepository->getList($searchCriteria)->getItems();
}
}
......@@ -13,9 +13,8 @@ declare(strict_types=1);
namespace Met\ExampleMagento2ModuleTesting\Test\Integration\Model;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Met\ExampleMagento2ModuleTesting\Model\Example;
use PHPUnit\Framework\TestCase;
/**
......@@ -26,19 +25,13 @@ use PHPUnit\Framework\TestCase;
class ExampleTest extends TestCase
{
/**
* @magentoDataFixtures Met_ExampleMagento2ModuleTesting::Test/Integration/_files/orders.php
* @magentoDataFixture Met_ExampleMagento2ModuleTesting::Test/Integration/_files/orders.php
*/
public function testSomething()
{
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
$searchCriteriaBuilder = Bootstrap::getObjectManager()->create(SearchCriteriaBuilder::class);
/** @var OrderRepositoryInterface $orderRepository */
$orderRepository = Bootstrap::getObjectManager()->get(OrderRepositoryInterface::class);
$searchCriteria = $searchCriteriaBuilder->create();
$orders = $orderRepository->getList($searchCriteria)->getItems();
/** @var Example $model */
$model = Bootstrap::getObjectManager()->create(Example::class);
$orders = $model->execute();
$this->assertCount(6, $orders);
}
}
......@@ -42,7 +42,7 @@
<!-- Semicolon-separated 'glob' patterns, that match global XML configuration files -->
<const name="TESTS_GLOBAL_CONFIG_DIR" value="../../../app/etc"/>
<!-- Whether to cleanup the application before running tests or not -->
<const name="TESTS_CLEANUP" value="enabled"/>
<const name="TESTS_CLEANUP" value="disabled"/>
<!-- Memory usage and estimated leaks thresholds -->
<!--<const name="TESTS_MEM_USAGE_LIMIT" value="1024M"/>-->
<const name="TESTS_MEM_LEAK_LIMIT" value=""/>
......@@ -69,4 +69,15 @@
<listener class="Magento\TestFramework\Event\PhpUnit"/>
<listener class="Magento\TestFramework\ErrorLog\Listener"/>
</listeners>
<!-- Code Coverage Whitelist -->
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">../../../../../../app/code/*/*</directory>
<exclude>
<directory suffix=".php">../../../../../../app/code/Magento</directory>
<directory suffix=".php">../../../../../../app/code/*/*/Test</directory>
<directory suffix="registration.php">../../../../../../app/code/*/*</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment