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

Rerun $contentService->updateContent() when it failed due to validation error the first time

    XMLWordPrintable

Details

    Description

      I am testing the float type. The field type is "Required" in the content type

      In the test I first try to publish a new version of the object where value is
      not set ( expecting error )

      I then try to set the fieldvalue and publish the draft again.. Then I get an
      exception where I really don't understand the message....:
      eZ\Publish\Core\Base\Exceptions\ContentValidationException: More than one field
      is set for translatable field definition 'flt' on language with code 'eng-GB'

      It seems to me that draft is in an unstable state if updateContent() fails due
      to validation error.

      Steps to reproduce
              $contentUpdate->setField( 'flt', null );
      
              try
              {
                  // Update the content draft
                  $draftVersion2 = $contentService->updateContent(
                      $draftVersion2->getVersionInfo(),
                      $contentUpdate );
                  $this->assertTrue( false, "Exception should have been thrown when 
      reqired field \"flt\" is not set" );
              }
              catch ( eZ\Publish\Core\Base\Exceptions\ContentValidationException $e 
      )
              {
                  $this->assertEquals( $e->getMessage(), 'Required field \'flt\' value 
      is empty', 'Message from exception was not as expected' );
              }
              
      
              //Update the “TF6”  object with an alphanumeric value
              //"1A"
              $contentUpdate->setField( 'flt', '1A' );
              try
              {
                  // Update the content draft
                  $draftVersion2 = $contentService->updateContent(
                      $draftVersion2->getVersionInfo(),
                      $contentUpdate ); // <--------- Exception is thrown here
                  $this->assertTrue( false, "Exception should have been thrown when 
      fieldvalue for  \"flt\" is of type string" );
              }
              catch ( eZ\Publish\Core\Base\Exceptions\InvalidArgumentType $e )
              {
                  $this->assertEquals( $e->getMessage(), 'Argument \'$inputValue\' 
      is invalid: expected value to be of type 
      \'eZ\Publish\Core\FieldType\Float\Value\', got \'string\'', 'Message from 
      exception was not as expected' );
              }
      
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            vl vl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 15 minutes
                2h 15m