mercredi 26 août 2015

Aspect-Mock unitTesting : can't doubleTest

laravel5 codeception aspect-mock

I am using the above-mentioned but "true" not returning.......

Model

class User extends Model
{
  public static function isEmailExist($email)
  {
  if ( ! isset($email)) return false;
  $hit = (int)User::where('email__c', $email)->count();
  if ($hit > 0) {
      return true;
  }
  return false;
  }
}

unitTest

<?php
require_once __DIR__.'/../../app/User.php';
use \AspectMock\Test as test;

class UserTest extends \Codeception\TestCase\Test
{
  /**
   * @var \UnitTester
   */
  protected $model;

  protected function _before()
  {
  }

  protected function _after()
  {
  }
  public function testisEmailExist()
  {
      $emailInstance = test::double('\App\User')->make();
      $emailInstanceProxy = test::double($emailInstance, ['count' => 1]);
      $emailClassProxy = test::double('\App\User', ['where' => $emailInstance]);
      $user = new \App\User();
      $this->assertEquals(true, $user->isEmailExist('test@co.jp'));
  }
}

I don't know return value of "where"method.  

I also tried besides this, but it isn't done. Do you know a good ideas?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1PxQNqA
via IFTTT

Aucun commentaire:

Enregistrer un commentaire