Skip to content

Commit

Permalink
Adds a couple of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davedevelopment committed Jan 30, 2017
1 parent b9bb7f2 commit 995d92b
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function isAbsolutePath($path)

require_once $hamcrestPath;

Mockery::globalHelpers();
/*
* Unset global variables that are no longer needed.
*/
Expand Down
62 changes: 62 additions & 0 deletions tests/Mockery/TraitsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/**
* Mockery
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://github.com/padraic/mockery/blob/master/LICENSE
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to padraic@php.net so we can send you a copy immediately.
*
* @category Mockery
* @package Mockery
* @copyright Copyright (c) 2017 Dave Marshall (dave@atst.io)
* @license http://github.com/padraic/mockery/blob/master/LICENSE New BSD License
*/

namespace test\Mockery;

use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;

class TraitTest extends \PHPUnit_Framework_TestCase
{
use MockeryPHPUnitIntegration;

/** @test */
public function it_can_create_an_object_for_a_simple_trait()
{
$trait = mock(SimpleTrait::class);

$this->assertEquals('bar', $trait->foo());
}

/** @test */
public function it_creates_abstract_methods_as_necessary()
{
$trait = mock(TraitWithAbstractMethod::class, ['doFoo' => 'baz']);

$this->assertEquals('baz', $trait->foo());
}
}

trait SimpleTrait
{
function foo()
{
return 'bar';
}
}

trait TraitWithAbstractMethod
{
function foo()
{
return $this->doFoo();
}

abstract function doFoo();
}

0 comments on commit 995d92b

Please sign in to comment.