Skip to content

Instantly share code, notes, and snippets.

View wowo's full-sized avatar

Wojciech Sznapka wowo

View GitHub Profile
$ ./bin/vendors update
<?php
namespace Wowo\Bundle\NewsletterBundle\Tests\Newsletter;
use lapistano\ProxyObject\ProxyObject;
class NewsletterManagerTest extends \PHPUnit_Framework_TestCase
{
public function testBuildBody()
{
$proxy = new ProxyObject();
@wowo
wowo / gist:1331766
Created November 1, 2011 20:12
deps file for Symfony2 and Mockery
[Mockery]
git=https://github.com/padraic/mockery.git
target=mockery
@wowo
wowo / autoload.php
Created November 1, 2011 20:16
Symfony2 autoload prepared for Mockery
<?php
// [...]
// you can put it on bottom of the autoload.php
if (class_exists('PHPUnit_Runner_Version')) {
set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__.'/../vendor/mockery/library/');
require_once('Mockery/Loader.php');
$loader = new \Mockery\Loader;
$loader->register();
}
@wowo
wowo / phpunit.xml
Created November 1, 2011 20:19
PHPUnit xml config with Mockery listener
<phpunit>
<!-- snip... -->
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener"
file="Mockery/Adapter/Phpunit/TestListener.php">
</listener>
</listeners>
</phpunit>
@wowo
wowo / PHPUnit way to mock Doctrine2 Entity Manager.php
Created November 1, 2011 20:22
PHPUnit's way to mock Doctrine2 Entity Manager
<?php
class AbstractManagerBase extends \PHPUnit_Framework_TestCase
{
protected function getEmMock()
{
$emMock = $this->getMock('\Doctrine\ORM\EntityManager',
array('getRepository', 'getClassMetadata', 'persist', 'flush'), array(), '', false);
$emMock->expects($this->any())
->method('getRepository')
@wowo
wowo / Mockery way to mock Doctrine2 Entity Manager.php
Created November 1, 2011 20:24
Mockery's way to mock Doctrine2 Entity Manager
<?php
class AbstractManagerBase extends \PHPUnit_Framework_TestCase
{
protected function getEmMock()
{
$emMock = \Mockery::mock('\Doctrine\ORM\EntityManager',
array(
'getRepository' => new FakeRepository(),
'getClassMetadata' => (object)array('name' => 'aClass'),
<?php
if (is_array($limiters['organization_unit']))
{
if (!empty($limiters['organization_unit']))
{
$units_conditions = '';
$first = true;
<?php
if (is_array($limiters['organization_unit']) && !empty($limiters['organization_unit']))
{
$query->andWhere($query->expr()->in('si.organizationUnitCode', $limiters['organization_unit']));
}
@wowo
wowo / bundles.txt
Created December 9, 2011 13:31
Bulk Symfony2 bundles generation.sh
FirstBundle
SecondBundle
AnotherBundle