Skip to content

Instantly share code, notes, and snippets.

View philipobenito's full-sized avatar

Phil Bennett philipobenito

  • Barnsley, Yorkshire, England
View GitHub Profile
<?php
function mockIteratorItems(\Iterator $iterator, array $items, $includeCallsToKey = false)
{
$iterator->expects($this->at(0))->method('rewind');
$counter = 1;
foreach ($items as $k => $v) {
$iterator->expects($this->at($counter++))->method('valid')->will($this->returnValue(true));
<?php
$container = new League\Container\Container;
$container->add('Zend\Diactoros\ServerRequest', function () {
return Zend\Diactoros\ServerRequestFactory::fromGlobals(
$_SERVER,
$_GET,
$_POST,
$_COOKIE,
Verifying that +philipobenito is my blockchain ID. https://onename.com/philipobenito
<?php
class Foo
{
public function doSomething($id, $name, $email)
{
$bar = new Bar;
// .. possibly manipulate $id, $name and $email
<?php
class Foo
{
protected $bar;
public function doSomething($bar, $id, $name, $email)
{
$this->bar = $bar;
// .. possibly manipulate $id, $name and $email
<?php
class FooTest extends PHPUnit_Framework_Testcase
{
public function testDoSomethingEditsDataAndReturnsArray()
{
$foo = new Foo;
$bar = new Bar;
$user = $foo->doSomething($bar, 1, , 'Phil', 'hello@example.com');
<?php
class FakeBar
{
public $users = [
1 => [
'name' => 'Adam',
'email' => 'adam@example.com'
]
];
<?php
class FooTest extends PHPUnit_Framework_Testcase
{
public function testDoSomethingEditsDataAndReturnsArray()
{
$foo = new Foo;
$user = [
'name' => 'Phil',
<?php
class FooTest extends PHPUnit_Framework_Testcase
{
public function testDoSomethingEditsDataAndReturnsArray()
{
$foo = new Foo;
$user = [
'name' => 'Phil',
# don't recommend running as one script
# list merged remote branches
git branch -a --merged live | grep -v live
# delete remote merged branches
git branch -a --merged live | grep -v live | xargs -n 1 git push --delete origin
# list merged local branches
git branch --merged live | grep -v live