8
0
Fork 1

improve integration tests

Dieser Commit ist enthalten in:
Daniel Seifert 2023-01-13 22:19:55 +01:00
Ursprung ea3489eaf3
Commit bb03bb1dee
Signiert von: DanielS
GPG-Schlüssel-ID: 6A513E13AEE66170
2 geänderte Dateien mit 50 neuen und 63 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

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