Skip to content

Instantly share code, notes, and snippets.

@agallou
Last active December 13, 2015 18:57
Show Gist options
  • Save agallou/5a7fe3b2598449271f5a to your computer and use it in GitHub Desktop.
Save agallou/5a7fe3b2598449271f5a to your computer and use it in GitHub Desktop.
<?php
require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$runner->addTest('test.php');
$runner->addExtension(new \mageekguy\atoum\visibility\extension($script));
<?php
require_once __DIR__ . '/vendor/autoload.php';
{
"require": {
"atoum/visibility-extension": "^1.0",
"atoum/atoum": "^2.4"
}
}
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "5df3e7619e40f2ea3c0dd253cecfc69f",
"content-hash": "abaa412f2c8db4cfc71cef7c3b18a967",
"packages": [
{
"name": "atoum/atoum",
"version": "2.4.1",
"source": {
"type": "git",
"url": "https://github.com/atoum/atoum.git",
"reference": "3b76b6f5086a58e0b6f7c89ba4e1882425853c13"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/atoum/atoum/zipball/3b76b6f5086a58e0b6f7c89ba4e1882425853c13",
"reference": "3b76b6f5086a58e0b6f7c89ba4e1882425853c13",
"shasum": ""
},
"require": {
"ext-hash": "*",
"ext-json": "*",
"ext-session": "*",
"ext-tokenizer": "*",
"ext-xml": "*",
"php": ">=5.3.3"
},
"replace": {
"mageekguy/atoum": "*"
},
"suggest": {
"atoum/stubs": "Provides IDE support (like autocompletion) for atoum",
"ext-mbstring": "Provides support for UTF-8 strings"
},
"bin": [
"bin/atoum"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
}
},
"autoload": {
"classmap": [
"classes/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD"
],
"authors": [
{
"name": "Frédéric Hardy",
"email": "frederic.hardy@atoum.org",
"homepage": "http://blog.mageekbox.net"
},
{
"name": "François Dussert",
"email": "francois.dussert@atoum.org"
},
{
"name": "Gérald Croes",
"email": "gerald.croes@atoum.org"
},
{
"name": "Julien Bianchi",
"email": "julien.bianchi@atoum.org"
},
{
"name": "Ludovic Fleury",
"email": "ludovic.fleury@atoum.org"
}
],
"description": "Simple modern and intuitive unit testing framework for PHP 5.3+",
"homepage": "http://www.atoum.org",
"keywords": [
"TDD",
"atoum",
"test",
"unit testing"
],
"time": "2015-12-07 14:57:39"
},
{
"name": "atoum/visibility-extension",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/atoum/visibility-extension.git",
"reference": "b9ec99da887c9106f63e5bfcedbb9eec811ebca5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/atoum/visibility-extension/zipball/b9ec99da887c9106f63e5bfcedbb9eec811ebca5",
"reference": "b9ec99da887c9106f63e5bfcedbb9eec811ebca5",
"shasum": ""
},
"require-dev": {
"atoum/atoum": "<3.0"
},
"type": "library",
"autoload": {
"psr-4": {
"mageekguy\\atoum\\visibility\\": "classes"
},
"files": [
"autoloader.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD"
],
"authors": [
{
"name": "jubianchi",
"email": "contact@jubianchi.fr"
}
],
"description": "atoum extension to loosen method visibility",
"homepage": "http://www.atoum.org",
"keywords": [
"TDD",
"atoum",
"test",
"unit testing",
"visibility"
],
"time": "2015-02-21 17:02:02"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}
<?php
namespace titi
{
class foo
{
public function baz()
{
return $this->bar();
}
private function bar()
{
return 'fail';
}
}
}
namespace titi\tests\units
{
use mageekguy\atoum;
class foo extends atoum\test
{
public function testBar()
{
$this
->given(
$this->mockGenerator
->makeVisible('bar')
->generate('\titi\foo')
)
->if($mockedSut = new \mock\titi\foo)
->and($this->calling($mockedSut)->bar = 'foo')
->then
->string($mockedSut->baz())->isEqualTo('foo')
->string($mockedSut->baz())->isEqualTo('foo')
->mock($mockedSut)
->call('bar')->twice()
;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment