Codeception / module-yii2

Codeception module for Yii2 framework
MIT License
16 stars 36 forks source link

Mock objects replacing triggers with dates #32

Closed jonny7 closed 2 years ago

jonny7 commented 5 years ago

Hi

I'm trying to mock out an object with a specific ENTERED_DT in my test like so:

        $partTopic = new PartTopic();
        $partTopic->PARTICIPANT_ID = 123;
        $partTopic->TOPIC_ID = 5;
        $partTopic->ENTERED_DT = new Expression("TRUNC(TO_DATE('20160101', 'YYYYMMDD'))");
        $partTopic->save();

The ENTERED_DT is normally done via an Oracle trigger. I can test that the object is created using seeRecord or print it out to the console which is returns:

 [ENTERED_DT] => yii\db\Expression Object
                  (
                      [expression] => TRUNC(TO_DATE('20160101', 'YYYYMMDD'))
                      [params] => Array
                          (
                          )

                  )

However when I unit test a query that then uses a between statement to find this record I always get 0 records returned. If I manually create this object in the DB it works though, so I guess is what I'm trying to do possible or am I missing something with this approach?