title: Make a Stub for nesting function in Yii2
body: <p>I learn to use Unit test in Yii2 with Codeception, and try to check if a billing is a &quot;daily&quot; billing from a merchant's setting.</p>
  <pre><code>$this-&gt;biller-&gt;merchant-&gt;detail-&gt;rule_type == self::PERIODIC_MODE_DAILY
  </code></pre>
  <p>I don't know how to mock that <code>rule_type</code> value if I use a <code>Stub::make()</code> function.</p>
  <p>What I tried so far is using the nested array like this (doesn't work) :</p>
  <pre><code>$billing = Stub::make(Billing::class, [
      'status'        =&gt; Billing::STATUS_ACTIVE,
      'set_periodic_by' =&gt; Billing::SET_PERIODIC_BY_MERCHANT,
      'biller' =&gt; [
          'merchant' =&gt; [
              'detail' =&gt; [
                  'rule_type' =&gt; Billing::PERIODIC_MODE_DAILY,
              ]
          ]
      ]
  ]);
  </code></pre>
  <p>And I also tried to mock each of the object model using another Stub::make()</p>
  <pre><code>$billing = Stub::make(Billing::class, [
      'status'        =&gt; Billing::STATUS_ACTIVE,
      'set_periodic_by' =&gt; Billing::SET_PERIODIC_BY_MERCHANT,
      'getBiller' =&gt; Stub::make(Biller::class, [
          'getMerchant' =&gt; Stub::make(Merchant::class, [
              'getDetail' =&gt; Stub::make(MerchantDetail::class, [
                  'rule_type' =&gt; Billing::PERIODIC_MODE_DAILY,
              ])
          ])
      ])
  ]);
  </code></pre>
  <p>How do I properly create a &quot;nested&quot; function return values using Stub? Any comment or answer is always welcome.</p>