Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

Commit

Permalink
Make module backward compatible for compilation 6.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkoltan committed Apr 24, 2019
1 parent ec48f76 commit 54bc212
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 20 deletions.
19 changes: 13 additions & 6 deletions services.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
services:

_defaults:
public: false
autowire: true

OxidEsales\GraphQl\Sample\Dao\CategoryDaoInterface:
class: OxidEsales\GraphQl\Sample\Dao\CategoryDao
public: false
autowire: true

OxidEsales\GraphQl\Sample\Type\ObjectType\CategoryType:
class: OxidEsales\GraphQl\Sample\Type\ObjectType\CategoryType
public: false
autowire: true

OxidEsales\GraphQl\Sample\Type\Provider\CategoryProvider:
class: OxidEsales\GraphQl\Sample\Type\Provider\CategoryProvider
tags: ['graphql_query_provider', 'graphql_mutation_provider']
public: false
autowire: true
tags:
- {name: 'graphql_query_provider'}
- {name: 'graphql_mutation_provider'}

OxidEsales\GraphQl\Sample\Service\CategoryPermissionsProvider:
class: OxidEsales\GraphQl\Service\PermissionsProvider
public: false
autowire: true
calls:
- ['addPermission', ['admin', 'mayaddcategory']]
- ['addPermission', ['shopadmin', 'mayaddcategory']]
tags: ['graphql_permissions_provider']
tags:
- {name: 'graphql_permissions_provider'}
56 changes: 42 additions & 14 deletions tests/Integration/Dao/CategoryDaoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,57 +8,85 @@

namespace OxidEsales\GraphQl\Sample\Tests\Integration\Dao;


use OxidEsales\EshopCommunity\Tests\Integration\Internal\TestContainerFactory;
use OxidEsales\GraphQl\Exception\ObjectNotFoundException;
use OxidEsales\GraphQl\Sample\Dao\CategoryDao;
use OxidEsales\GraphQl\Sample\Dao\CategoryDaoInterface;
use PHPUnit\Framework\TestCase;
use OxidEsales\GraphQl\Tests\Integration\ContainerTrait;

class CategoryDaoTest extends TestCase
class CategoryDaoTest extends \PHPUnit_Framework_TestCase
{

use ContainerTrait;
/** @var CategoryDao $categoryDao */
private $categoryDao;

/** @var string $categoryIdRoot */
private $categoryIdRoot;

/** @var string $categoryIdSub1 */
private $categoryIdSub1;

/** @var string $categoryIdSub2 */
private $categoryIdSub2;

public function setUp()
{
$containerFactory = new TestContainerFactory();
$container = $containerFactory->create();
$container = $this->createUncompiledContainer();
$container->compile();
$this->categoryDao = $container->get(CategoryDaoInterface::class);

$this->categoryIdRoot = $this->categoryDao->addCategory(['Test deutsch', 'Test english'], 1);
$this->categoryIdSub1 = $this->categoryDao->addCategory(['Unterkategorie 1', 'sub category 1'], 1,
$this->categoryIdRoot);
$this->categoryIdSub2 = $this->categoryDao->addCategory(['Unterkategorie 2', 'sub category 2'], 1,
$this->categoryIdRoot);
}

public function testGetCategory()
{
$category = $this->categoryDao->getCategory('30e44ab834ea42417.86131097', 'de', 1);
$this->assertEquals('30e44ab834ea42417.86131097', $category->getId());
$this->assertEquals('Für Ihn', $category->getName());
$category = $this->categoryDao->getCategory($this->categoryIdRoot, 'de', 1);
$this->assertEquals($this->categoryIdRoot, $category->getId());
$this->assertEquals('Test deutsch', $category->getName());

}

public function testGetCategoryOtherShop()
{
$this->expectExceptionMessage('Category with id "30e44ab834ea42417.86131097" not found.');
$this->categoryDao->getCategory('30e44ab834ea42417.86131097', 'de', 2);
$this->setExpectedException(ObjectNotFoundException::class, 'Category with id "'. $this->categoryIdRoot .
'" not found.');
$this->categoryDao->getCategory($this->categoryIdRoot, 'de', 2);

}

public function testGetCategoryWithWrongId()
{
$this->expectException(\Exception::class);
$this->setExpectedException(\Exception::class);
$this->categoryDao->getCategory('somenonexistingid', 'de', 1);
}

public function testGetRootCategories()
{
$rootCategories = $this->categoryDao->getCategories('de', 1);
$this->assertEquals(7, sizeof($rootCategories));
$found = false;
foreach ($rootCategories as $rootCategory) {
/** @var \OxidEsales\GraphQl\Sample\DataObject\Category $rootCategory */
if ($rootCategory->getId() == $this->categoryIdRoot) {
$found = true;
}
if ($rootCategory->getId() == $this->categoryIdSub1) {
$this->fail('This should not be in the list of root categories.');
}
if ($rootCategory->getId() == $this->categoryIdSub2) {
$this->fail('This should not be in the list of root categories.');
}
}
$this->assertTrue($found);

}

public function testGetSubCategories()
{
$subCategories = $this->categoryDao->getCategories('de', 1, '30e44ab834ea42417.86131097');
$subCategories = $this->categoryDao->getCategories('de', 1, $this->categoryIdRoot);
$this->assertEquals(2, sizeof($subCategories));
}

Expand Down

0 comments on commit 54bc212

Please sign in to comment.