Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-29291

[Content Type] redis cache doesn't refresh automatically when creating CT with API in behat tests

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: 2.2.0, 1.7.7
    • Fix Version/s: 2.5.0-rc2
    • Component/s: QA
    • Labels:

      Description

      When behat tests creates new Content Type through API in method

      EzSystems\RepositoryForms\Features\Context\FieldTypeFormContext::aContentTypeWithAGivenFieldDefinition

      then the redis cache is not refreshing automatically (we need to manually FLUSHALL). The same command executed with console command (php bin/console ez-support-tools:create-ct) works fine and refresh properly.

      <?php
      
      /**
       * File containing the SystemInfoDumpCommand class.
       *
       * @copyright Copyright (C) eZ Systems AS. All rights reserved.
       * @license For full copyright and license information view LICENSE file distributed with this source code.
       */
      namespace EzSystems\EzSupportToolsBundle\Command;
      
      use EzSystems\EzSupportToolsBundle\SystemInfo\SystemInfoCollectorRegistry;
      use EzSystems\EzSupportToolsBundle\SystemInfo\OutputFormatRegistry;
      use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
      use Symfony\Component\Console\Input\InputArgument;
      use Symfony\Component\Console\Input\InputOption;
      use Symfony\Component\Console\Input\InputInterface;
      use eZ\Publish\API\Repository\Values\ContentType\FieldDefinitionCreateStruct;
      use Symfony\Component\Console\Output\OutputInterface;
      
      class SystemInfoDumpCommand extends ContainerAwareCommand
      {
          /**
           * System info collector registry.
           *
           * @var \EzSystems\EzSupportToolsBundle\SystemInfo\SystemInfoCollectorRegistry
           */
          private $systemInfoCollectorRegistry;
      
          /**
           * Output format registry.
           *
           * @var \EzSystems\EzSupportToolsBundle\SystemInfo\OutputFormatRegistry
           */
          private $outputFormatRegistry;
      
          public function __construct(SystemInfoCollectorRegistry $systemInfoCollectorRegistry, OutputFormatRegistry $outputFormatRegistry)
          {
              $this->systemInfoCollectorRegistry = $systemInfoCollectorRegistry;
              $this->outputFormatRegistry = $outputFormatRegistry;
      
              parent::__construct();
          }
      
          /**
           * Define command and input options.
           */
          protected function configure()
          {
              $this
                  ->setName('ez-support-tools:create-ct')
                  ;
          }
      
          /**
           * Execute the Command.
           *
           * @param $input InputInterface
           * @param $output OutputInterface
           */
          protected function execute(InputInterface $input, OutputInterface $output)
          {
              $repository = $this->getContainer()->get( 'ezpublish.api.repository');
              $contentTypeService = $repository->getContentTypeService();
      
              $userService = $repository->getUserService();
              $username = 'admin';
              $password = 'publish';
      
              $permissionResolver = $repository->getPermissionResolver();
              $user = $userService->loadUserByCredentials( $username, $password );
              $permissionResolver->setCurrentUserReference($user);
      
              $id = 'content_type_' . uniqid();
              $contentTypeCreateStruct = $contentTypeService->newContentTypeCreateStruct($id);
      
              $fieldDefinition = [
                  'identifier' => 'Field',
                  'fieldTypeIdentifier' => 'ezstring',
                  'names' => ['eng-GB' => 'Field'],
              ];
      
              $contentTypeCreateStruct->addFieldDefinition(new FieldDefinitionCreateStruct($fieldDefinition));
              $contentTypeCreateStruct->mainLanguageCode = 'eng-GB';
              $contentTypeCreateStruct->names = ['eng-GB' => $id];
      
              $contentTypeService->publishContentTypeDraft(
                  $contentTypeService->createContentType(
                      $contentTypeCreateStruct,
                      [$contentTypeService->loadContentTypeGroupByIdentifier('Content')]
                  )
              );
          }
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                maciej.tyrala@ez.no Maciej TyraƂa
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: