improve integration tests

This commit is contained in:
Daniel Seifert 2023-01-13 22:19:55 +01:00
parent ea3489eaf3
commit bb03bb1dee
Signed by: DanielS
GPG Key ID: 6A513E13AEE66170
2 changed files with 50 additions and 63 deletions

View File

@ -17,6 +17,7 @@ namespace D3\Linkmobility4OXID\tests\integration;
use D3\Linkmobility4OXID\Application\Controller\Admin\AdminOrder;
use D3\Linkmobility4OXID\Application\Model\Configuration;
use Doctrine\DBAL\Exception as DoctrineException;
use Doctrine\DBAL\Query\QueryBuilder;
use Exception;
use GuzzleHttp\Exception\RequestException;
@ -30,6 +31,8 @@ use OxidEsales\Eshop\Core\Registry;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Http\Message\RequestInterface;
class adminOrderTest extends LMIntegrationTestCase
@ -45,12 +48,13 @@ class adminOrderTest extends LMIntegrationTestCase
/** @var Configuration|MockObject $configuration */
$configuration = $this->getMockBuilder(Configuration::class)
->onlyMethods(['getTestMode'])
->onlyMethods(['getTestMode', 'sendOrderFinishedMessage'])
->getMock();
$configuration->method('getTestMode')->willReturn(true);
$configuration->method('sendOrderFinishedMessage')->willReturn(false);
d3GetOxidDIC()->set(Configuration::class, $configuration);
/** @var User $order */
/** @var Order $order */
$this->order = $order = oxNew( Order::class);
$order->setId($this->orderId);
$order->assign([
@ -68,9 +72,9 @@ class adminOrderTest extends LMIntegrationTestCase
/**
* @test
* @throws \Doctrine\DBAL\Exception
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws DoctrineException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function succSending()
{
@ -127,18 +131,16 @@ class adminOrderTest extends LMIntegrationTestCase
)
);
$remarkIds = $queryBuilder->execute()->fetchAll();
$this->assertTrue(
count($remarkIds) > 0
);
$this->assertNotEmpty($remarkIds);
$this->deleteAllRemarksFrom($this->userId);
}
/**
* @test
* @throws \Doctrine\DBAL\Exception
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws DoctrineException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function apiError()
{
@ -196,18 +198,16 @@ class adminOrderTest extends LMIntegrationTestCase
)
);
$remarkIds = $queryBuilder->execute()->fetchAll();
$this->assertTrue(
count($remarkIds) == 0
);
$this->assertEmpty($remarkIds);
$this->deleteAllRemarksFrom($this->userId);
}
/**
* @test
* @throws \Doctrine\DBAL\Exception
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws DoctrineException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function emptyMessage()
{
@ -260,18 +260,16 @@ class adminOrderTest extends LMIntegrationTestCase
)
);
$remarkIds = $queryBuilder->execute()->fetchAll();
$this->assertTrue(
count($remarkIds) == 0
);
$this->assertEmpty($remarkIds);
$this->deleteAllRemarksFrom($this->userId);
}
/**
* @test
* @throws \Doctrine\DBAL\Exception
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws DoctrineException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function recipientError()
{
@ -330,18 +328,16 @@ class adminOrderTest extends LMIntegrationTestCase
)
);
$remarkIds = $queryBuilder->execute()->fetchAll();
$this->assertTrue(
count($remarkIds) == 0
);
$this->assertEmpty($remarkIds);
$this->deleteAllRemarksFrom($this->userId);
}
/**
* @test
* @throws \Doctrine\DBAL\Exception
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws DoctrineException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function communicationError()
{
@ -398,9 +394,7 @@ class adminOrderTest extends LMIntegrationTestCase
)
);
$remarkIds = $queryBuilder->execute()->fetchAll();
$this->assertTrue(
count($remarkIds) == 0
);
$this->assertEmpty($remarkIds);
$this->deleteAllRemarksFrom($this->userId);
}

View File

@ -16,7 +16,8 @@ declare(strict_types=1);
namespace D3\Linkmobility4OXID\tests\integration;
use D3\Linkmobility4OXID\Application\Model\Configuration;
use \D3\Linkmobility4OXID\Application\Controller\Admin\AdminUser;
use D3\Linkmobility4OXID\Application\Controller\Admin\AdminUser;
use Doctrine\DBAL\Exception as DoctrineException;
use Doctrine\DBAL\Query\QueryBuilder;
use Exception;
use GuzzleHttp\Exception\RequestException;
@ -29,6 +30,8 @@ use OxidEsales\Eshop\Core\Registry;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Http\Message\RequestInterface;
class adminUserTest extends LMIntegrationTestCase
@ -60,9 +63,9 @@ class adminUserTest extends LMIntegrationTestCase
/**
* @test
* @throws \Doctrine\DBAL\Exception
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws DoctrineException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function succSending()
{
@ -119,18 +122,16 @@ class adminUserTest extends LMIntegrationTestCase
)
);
$remarkIds = $queryBuilder->execute()->fetchAll();
$this->assertTrue(
count($remarkIds) > 0
);
$this->assertNotEmpty($remarkIds);
$this->deleteAllRemarksFrom($this->userId);
}
/**
* @test
* @throws \Doctrine\DBAL\Exception
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws DoctrineException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function apiError()
{
@ -188,18 +189,16 @@ class adminUserTest extends LMIntegrationTestCase
)
);
$remarkIds = $queryBuilder->execute()->fetchAll();
$this->assertTrue(
count($remarkIds) == 0
);
$this->assertEmpty($remarkIds);
$this->deleteAllRemarksFrom($this->userId);
}
/**
* @test
* @throws \Doctrine\DBAL\Exception
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws DoctrineException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function emptyMessage()
{
@ -252,18 +251,16 @@ class adminUserTest extends LMIntegrationTestCase
)
);
$remarkIds = $queryBuilder->execute()->fetchAll();
$this->assertTrue(
count($remarkIds) == 0
);
$this->assertEmpty($remarkIds);
$this->deleteAllRemarksFrom($this->userId);
}
/**
* @test
* @throws \Doctrine\DBAL\Exception
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws DoctrineException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function recipientError()
{
@ -322,18 +319,16 @@ class adminUserTest extends LMIntegrationTestCase
)
);
$remarkIds = $queryBuilder->execute()->fetchAll();
$this->assertTrue(
count($remarkIds) == 0
);
$this->assertEmpty($remarkIds);
$this->deleteAllRemarksFrom($this->userId);
}
/**
* @test
* @throws \Doctrine\DBAL\Exception
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws DoctrineException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function communicationError()
{
@ -390,9 +385,7 @@ class adminUserTest extends LMIntegrationTestCase
)
);
$remarkIds = $queryBuilder->execute()->fetchAll();
$this->assertTrue(
count($remarkIds) == 0
);
$this->assertEmpty($remarkIds);
$this->deleteAllRemarksFrom($this->userId);
}