Skip to content

Instantly share code, notes, and snippets.

@chukShirley
Last active July 15, 2016 17:25
Show Gist options
  • Save chukShirley/71cba1ff64be308ce18857c7184c5cfb to your computer and use it in GitHub Desktop.
Save chukShirley/71cba1ff64be308ce18857c7184c5cfb to your computer and use it in GitHub Desktop.
<?php
namespace Temp;
use ToolkitApi\Toolkit;
class Dummy
{
/** @var Toolkit */
private $ibmiToolkit;
/**
* Dummy constructor.
* @param Toolkit $ibmiToolkit
*/
public function __construct(Toolkit $ibmiToolkit)
{
$this->ibmiToolkit = $ibmiToolkit;
}
public function dummyMethod()
{
return $this->ibmiToolkit->AddParameterPackDec('both', 9, 0, 'SRN', 'SRN', 0);
}
}
<?php
namespace TempTest;
use PHPUnit_Framework_TestCase;
use Temp\Dummy;
use ToolkitApi\Toolkit;
class DummyTest extends PHPUnit_Framework_TestCase
{
public function testDummyMethod()
{
$ibmiToolkit = $this->getMockBuilder(Toolkit::class)
->disableOriginalConstructor()
->getMock();
$ibmiToolkit->expects(self::any())
->method('AddParameterPackDec')
->withAnyParameters()
->willReturn('test');
/** @var Toolkit $ibmiToolkit */
$dummy = new Dummy(
$ibmiToolkit
);
$this->assertEquals('test', $dummy->dummyMethod());
}
}
@bradynpoulsen
Copy link

@chukShirley I haven't seen ->withAnyParameters() before, but instead ->with($this->any())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment