+{
+ my $cf = RT::Test->load_or_create_custom_field(
+ Name => 'HasEntry cache',
+ Type => 'FreeformSingle',
+ Queue => 0,
+ );
+
+ my ( $ret, $msg ) = $ticket->AddCustomFieldValue( Field => $cf, Value => 'foo' );
+ ok( $ret, $msg );
+ is( $ticket->FirstCustomFieldValue( $cf ), 'foo', 'value is foo' );
+ my $ocfvs = $ticket->CustomFieldValues( $cf );
+ ok( $ocfvs->HasEntry( 'foo' ), 'foo is cached in HasEntry' );
+
+ ( $ret, $msg ) = $ticket->AddCustomFieldValue( Field => $cf, Value => 'bar' );
+ ok( $ret, $msg );
+ is( $ticket->FirstCustomFieldValue( $cf ), 'bar', 'value is bar' );
+ ok( !$ocfvs->HasEntry( 'foo' ), 'foo is not cached in HasEntry' );
+ ok( $ocfvs->HasEntry( 'bar' ), 'bar is cached in HasEntry' );
+
+ ( $ret, $msg ) = $ticket->AddCustomFieldValue( Field => $cf, Value => 'foo' );
+ ok( $ret, $msg );
+ is( $ticket->FirstCustomFieldValue( $cf ), 'foo', 'value is foo' );
+ ok( $ocfvs->HasEntry( 'foo' ), 'foo is cached in HasEntry' );
+ ok( !$ocfvs->HasEntry( 'bar' ), 'bar is not cached in HasEntry' );
+}
+