setRepositoryFactory example

protected ?ObjectManager $em;
    protected ManagerRegistry $registry;
    protected MockObject&EntityRepository $repository;
    protected TestRepositoryFactory $repositoryFactory;

    protected function setUp(): void
    {
        $this->repositoryFactory = new TestRepositoryFactory();

        $config = DoctrineTestHelper::createTestConfiguration();
        $config->setRepositoryFactory($this->repositoryFactory);

        if (!Type::hasType('string_wrapper')) {
            Type::addType('string_wrapper', StringWrapperType::class);
        }

        $this->em = DoctrineTestHelper::createTestEntityManager($config);
        $this->registry = $this->createRegistryMock($this->em);
        $this->createSchema($this->em);

        parent::setUp();
    }

    

    public function __construct(array $options, Zend_Cache_Core $cache, RepositoryFactory $repositoryFactory, ShopwareReleaseStruct $release)
    {
        // Specifies the FQCN of a subclass of the EntityRepository.         // That will be available for all entities without a custom repository class.         $this->setDefaultRepositoryClassName('Shopware\Components\Model\ModelRepository');

        $this->setProxyDir($options['proxyDir']);
        $this->setProxyNamespace($options['proxyNamespace']);

        $this->setRepositoryFactory($repositoryFactory);
        $this->setAutoGenerateProxyClasses(AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS);

        $this->setAttributeDir($options['attributeDir']);

        Type::overrideType('datetime', \Shopware\Components\Model\DBAL\Types\DateTimeStringType::class);
        Type::overrideType('date', \Shopware\Components\Model\DBAL\Types\DateStringType::class);
        Type::overrideType('array', \Shopware\Components\Model\DBAL\Types\AllowInvalidArrayType::class);

        $this->addCustomStringFunction('DATE_FORMAT', DateFormat::class);
        $this->addCustomStringFunction('IFNULL', IfNull::class);
        $this->addCustomStringFunction('IF', IfElse::class);
        
Home | Imprint | This part of the site doesn't use cookies.