OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

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

This topic contains 8 replies, has 3 voices, and was last updated by  Kacper 4 years, 4 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #34500

    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 8 replies - 1 through 8 (of 8 total)
  • Author
    Replies
  • #34501

    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?


    #34502

    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.

    #34503

    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.


    #34504

    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.

    #34505

    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.

    #34506

    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.


    #34507

    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

    #40841

    Kacper
    Participant

    @msulima: I have the same problem

    do you have any idea where to look for solution? I created another discussion here: here

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

The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.

Back to top