/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { parent::setUp(); Shopware()->Models()->clear(); $this->resourceArticle = new \Shopware\Components\Api\Resource\Article(); $this->resourceArticle->setAcl(Shopware()->Acl()); $this->resourceArticle->setManager(Shopware()->Models()); }
public function __construct() { $this->db = Shopware()->Db(); $this->entityManager = Shopware()->Models(); $this->converter = new Converter(); $api = new Resource\Article(); $api->setManager($this->entityManager); $this->articleApi = $api; $variantApi = new Resource\Variant(); $variantApi->setManager($this->entityManager); $this->variantApi = $variantApi; $translation = new Resource\Translation(); $translation->setManager($this->entityManager); $this->translationApi = $translation; $categoryApi = new Resource\Category(); $categoryApi->setManager($this->entityManager); $this->categoryApi = $categoryApi; }
/** * deletes the Trusted Shops articles from the database if shop owner has * no Excellence service anymore * * @throws Exception * @throws NotFoundException * @throws ParameterMissingException */ public function deleteTrustedShopsArticles() { $builder = $this->getQueryBuilder(); $tsIds = $builder->getQuery()->getArrayResult(); if (empty($tsIds)) { return; } /* @var Article $articleResource */ $articleResource = new Article(); $articleResource->setManager($this->em); try { foreach ($tsIds as $tsId) { $articleResource->delete($tsId['id']); } } catch (ValidationException $e) { $errors = array(); /** @var ConstraintViolation $violation */ foreach ($e->getViolations() as $violation) { $errors[] = sprintf('%s: %s', $violation->getPropertyPath(), $violation->getMessage()); } throw new Exception(implode(', ', $errors)); } }
public function setUp() { $this->resource = new \Shopware\Components\Api\Resource\Article(); $this->resource->setManager(Shopware()->Models()); parent::setUp(); }