title: UnitTest object mocking or real object
body: <p>I had a discussion with my Team Lead, regarding UnitTest, the question was, 
  In UnitTest do we use Object Mocking or use the Real Object?
  I was supporting the Object Mocking concept, as we should only input/output data from Objects.</p>
  
  <p>At the end we agreed to use Real object instead of Mocking so the following was my Test</p>
  
  <pre><code>&lt;?php
  
  namespace App\Services\Checkout\Module\PaymentMethodRules;
  
  use App\Library\Payment\Method;
  use App\Services\Checkout\Module\PaymentMethodRuleManager;
  
  class AdminRule implements PaymentMethodRule
  {
      /**
       * @var boolean
       */
      private $isAdmin;
  
      /**
       * @var bool
       */
      private $isBankTransferAvailable;
  
      /**
       * @param boolean $isAdmin
       * @param bool $isBankTransferAvailable
       */
      public function __construct($isAdmin, $isBankTransferAvailable)
      {
          $this-&gt;isAdmin = $isAdmin;
          $this-&gt;isBankTransferAvailable = $isBankTransferAvailable;
      }
  
      /**
       * @param PaymentMethodRuleManager $paymentMethodRuleManager
       */
      public function run(PaymentMethodRuleManager $paymentMethodRuleManager)
      {
          if ($this-&gt;isAdmin) {
              $paymentMethodRuleManager-&gt;getList()-&gt;add([Method::INVOICE]);
          }
  
          if ($this-&gt;isAdmin &amp;&amp; $this-&gt;isBankTransferAvailable) {
              $paymentMethodRuleManager-&gt;getList()-&gt;add([Method::BANK_TRANSFER]);
          }
      }
  }
  
  
  
  &lt;?php
  namespace tests\Services\Checkout\Module;
  
  use App\Library\Payment\Method;
  use App\Services\Checkout\Module\PaymentMethodList;
  use App\Services\Checkout\Module\PaymentMethodRuleManager;
  use App\Services\Checkout\Module\PaymentMethodRules\AdminRule;
  
  class AdminRuleTest extends \PHPUnit_Framework_TestCase
  {
      const IS_ADMIN = true;
      const IS_NOT_ADMIN = false;
      const IS_BANK_TRANSFER = true;
      const IS_NOT_BANK_TRANSFER = false;
  
      /**
       * @test
       * @dataProvider runDataProvider
       *
       * @param bool $isAdmin
       * @param bool $isBankTransferAvailable
       * @param array $expected
       */
      public function runApplies($isAdmin, $isBankTransferAvailable, $expected)
      {
          $paymentMethodRuleManager = new PaymentMethodRuleManager(
              new PaymentMethodList([]),
              new PaymentMethodList([])
          );
  
          $adminRule = new AdminRule($isAdmin, $isBankTransferAvailable);
          $adminRule-&gt;run($paymentMethodRuleManager);
  
          $this-&gt;assertEquals($expected, $paymentMethodRuleManager-&gt;getList()-&gt;get());
      }
  
      /**
       * @return array
       */
      public function runDataProvider()
      {
          return [
              [self::IS_ADMIN, self::IS_BANK_TRANSFER, [Method::INVOICE, Method::BANK_TRANSFER]],
              [self::IS_ADMIN, self::IS_NOT_BANK_TRANSFER, [Method::INVOICE]],
              [self::IS_NOT_ADMIN, self::IS_BANK_TRANSFER, []],
              [self::IS_NOT_ADMIN, self::IS_NOT_BANK_TRANSFER, []]
          ];
      }
  }
  </code></pre>
  
  <p>My question is, in Unit Test should is use Real Objects or Object Mocking and why?
  Second Question, the given Unit test is right or wrong in terms of Unit testing.</p>