Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

Forums OroPlatform OroPlatform – Programming Questions Functional tests, how to access extended entities methods (custom attributes)

This topic contains 7 replies, has 2 voices, and was last updated by  nevoeiro 4 months ago.

  • Creator
    Topic
  • #1684

    nevoeiro
    Participant

    Hi,
    I extended ContentNode entity adding a new field ‘image’. And on my custom frontend controller I’m passing the image to the view. And everything is working as intended.
    My problem now is that I’m writing a functional test for my controller and I’m having this issue when it executes the request:

    The ‘image’ is called on my twig file, of my custom page, and this is a twig exception.

    Looks like on functional tests there are no access to extended generated classes, am I right?

    An approach I tried was create a Stub class that extends ContentNode, but I got the error ‘Class ContentNodeStub not found’.

    Are there a way to solve this? How can we access custom fields (added to core entities) on functional tests?

    Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Author
    Replies
  • #1685
    msulima
    msulima
    Moderator

    Hello,
    few questions:
    1. how you created new field?
    2. was application installed for test environment with that field and have valid cache for test environment?


    #1686

    nevoeiro
    Participant

    @msulima
    1. Field was created through a migration using AttachmentExtensionAwareInterface, like

    2. What do you mean with “installed for test environment” ? Like running ‘console oro:platform:update –env=test’? I didn’t run that.

    The installation has cache for test, I checked the app/cache/test/ folder, it has content and I can see the file ‘htdocs/app/cache/test/oro_entities/Extend/Entity/EX_OroWebCatalogBundle_ContentNode.php’. But image field isn’t there.

    On htdocs/app/cache/dev/oro_entities/Extend/Entity/EX_OroWebCatalogBundle_ContentNode.php I can see the image field there.

    #1687
    msulima
    msulima
    Moderator

    Are you use ane database for test and dev (prod) environment?
    Also yes, please run ‘console oro:platform:update –env=test’ to apply you migration and make sure that application cache for test environment was cleared.


    #1688

    nevoeiro
    Participant

    Thanks msulima!
    Yes, we have one for test and other for dev/prod.

    I run ‘console oro:platform:update –env=test’ and I got the extended class updated with the custom ‘image’ field. Now my tests are running successfully! Thanks.

    #1689

    nevoeiro
    Participant

    Hi again,

    We update to 1.6.0 version and it’s strange now we are getting a similar issue.
    When it tries to load the data for functional test:

    We get the error below on “$manager->persist($childNode);” execution:

    We checked on htdocs/app/cache/test/oro_entities/Extend/Entity/EX_OroWebCatalogBundle_ContentNode.php the field $metaTitles is there.

    #1690
    msulima
    msulima
    Moderator

    Hello,
    just tested your fixture. I copied and paste you code in my php class and run functional test with this fixture. I don’t have any errors.
    Please, try to clear cache for test env.


    #1691

    nevoeiro
    Participant

    Hi msulima

    Thanks for reply, we found the issue. It was a side effect from other new unit test added recently that was broken the cache generation.
    It was not clear because when we run the test isolated we didn’t got the issue, but when we tried to run all tests the issue came up in our pipeline.
    So it’s fine.
    thanks

Viewing 7 replies - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

You will be redirected to [title]. Would you like to continue?

Yes No
ssossossosso