菜谱项目

EloquentUserAdapterTest.php 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /*
  3. * This file is part of jwt-auth.
  4. *
  5. * (c) Sean Tymon <tymon148@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Tymon\JWTAuth\Test\Providers\User;
  11. use Mockery;
  12. use Tymon\JWTAuth\Providers\User\EloquentUserAdapter;
  13. class EloquentUserAdapterTest extends \PHPUnit_Framework_TestCase
  14. {
  15. public function setUp()
  16. {
  17. $this->builder = Mockery::mock('Illuminate\Database\Query\Builder');
  18. $this->model = Mockery::mock('Illuminate\Database\Eloquent\Model');
  19. $this->user = new EloquentUserAdapter($this->model);
  20. }
  21. public function tearDown()
  22. {
  23. Mockery::close();
  24. }
  25. /** @test */
  26. public function it_should_return_the_user_if_found()
  27. {
  28. $this->builder->shouldReceive('first')->once()->withNoArgs()->andReturn((object) ['id' => 1]);
  29. $this->model->shouldReceive('where')->once()->with('foo', 'bar')->andReturn($this->builder);
  30. $user = $this->user->getBy('foo', 'bar');
  31. $this->assertEquals(1, $user->id);
  32. }
  33. }