Skip to content

Instantly share code, notes, and snippets.

@sknuell
sknuell / PHPNativeFunctionMock.php
Last active February 10, 2021 22:22
Mocking native PHP functions (date(), time() and shell_exec) for PHPUnit using php-mock/php-mock and php-mock/php-mock-phpunit
<?php
namespace Foo\Bar;
use phpmock\MockBuilder;
use phpmock\phpunit\PHPMock;
use PHPUnit_Framework_TestCase;
class Baz
{
/**
@sknuell
sknuell / gist:5371653
Created April 12, 2013 12:24
Using Traits for injecting Services/Helpers
<?php
// helper trait
namespace Foo\Controller\Helper;
trait RedirectorHelper
{
private $_redirectorHelper;
public function injectRedirectorHelper(RedirectorHelper $helper)
{