Skip to content

Instantly share code, notes, and snippets.

View cakper's full-sized avatar
🎯
Focusing

Kacper Gunia cakper

🎯
Focusing
View GitHub Profile
@cakper
cakper / KernelAwareTest.php
Created November 17, 2011 12:47 — forked from jakzal/KernelAwareTest.php
KernelAwareTest
<?php
require_once dirname(__DIR__).'/../../../../app/AppKernel.php';
/**
* Test case class helpful with Entity tests requiring the database interaction.
* For regular entity tests it's better to extend standard \PHPUnit_Framework_TestCase instead.
*/
abstract class KernelAwareTest extends \PHPUnit_Framework_TestCase
{
@cakper
cakper / gist:1385149
Created November 22, 2011 08:04
Prepare entity Manager
<?php
use Symfony\Component\Validator\ValidatorFactory;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\IndexedReader;
/**
* Prepare entity manager for testing LifeCycleCallbacks
*/
@cakper
cakper / gist:1385152
Created November 22, 2011 08:05
Test CreatedAt and Updated At
public function testThatCreateAndUpdateDatesAreRegisteredAndIdGenerated()
{
$this->prepareEntityManager();
$now = new \DateTime('now');
$moneyTransaction = $this->moneyTransaction;
$validator = $this->validator;
$recipient = new \Jazzy\UserBundle\Entity\User();
@cakper
cakper / gist:1385372
Created November 22, 2011 10:24
set get amount
<?php
/**
* Set amount
*
* @param bigint $amount
*/
public function setAmount($amount)
{
if (is_int($amount) || is_float($amount))
{
@cakper
cakper / gist:1386347
Created November 22, 2011 17:47
Build.xml for Symfony2
<?xml version="1.0" encoding="UTF-8"?>
<project name="SS" default="build">
<target name="build"
depends="prepare,lint,phploc,pdepend,phpmd-ci,phpcs-ci,phpcpd,phpunit,phpcb"/>
<target name="build-parallel"
depends="prepare,lint,tools-parallel,phpunit,phpcb"/>
<target name="tools-parallel"
@cakper
cakper / gist:1391994
Created November 24, 2011 18:45
Bills test
<?php
public function getBills()
{
return array(
array(
120,
array(
array(120, 10, 25, false, 85),
array(0, 10, 25, false, -35),
array(0, 0, 25, false, -25),
@cakper
cakper / gist:1446386
Created December 8, 2011 07:29
Doctrine not working eager loading
<?php
$query = $em->createQuery('SELECT t FROM JazzyTransactionBundle:MoneyTransaction t WHERE t.sender = :user')->setParameter('user', $user);
$query->setFetchMode("JazzyTransactionBundle:MoneyTransaction", "sender", "EAGER");
$transactions = $query->execute();
WORKING:
@cakper
cakper / build.xml
Created December 29, 2011 22:24
Jenkins build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="SquareShare" default="build">
<target name="build"
depends="prepare,lint,phploc,pdepend,phpmd-ci,phpcs-ci,phpcpd,phpunit,phpcb"/>
<target name="build-parallel"
depends="prepare,lint,tools-parallel,phpunit,phpcb"/>
<target name="tools-parallel"
@cakper
cakper / composer_warnings
Created March 19, 2012 07:54
php composer.phar update
1 Updating dependencies
2 PHP Warning: assert(): Assertion failed in phar:///home/cakper/public_html/square/composer.phar/src/Composer/DependencyResolver/Solver.php on line 1112
3 PHP Stack trace:
4 PHP 1. {main}() /home/cakper/public_html/square/composer.phar:0
5 PHP 2. require() /home/cakper/public_html/square/composer.phar:15
6 PHP 3. Composer\Console\Application->run() phar:///home/cakper/public_html/square/composer.phar/bin/composer:9
7 PHP 4. Symfony\Component\Console\Application->run() phar:///home/cakper/public_html/square/composer.phar/src/Composer/Console/Application.php:58
8 PHP 5. Composer\Console\Application->doRun() phar:///home/cakper/public_html/square/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:106
9 PHP 6. Symfony\Component\Console\Application->doRun() phar:///home/cakper/public_html/square/composer.phar/src/Composer/Console/Application.php:69
10 PHP 7. Symfony\Component\Console\Command\Command->run() ph
@cakper
cakper / gist:2407644
Created April 17, 2012 17:30
Sahi error
<div id="friend-picker-container">
<ul class="friend-container">
<li style="display: none;">
<div class="friend-container">
<span class="user-data">Me</span>
<button class="btn"><i class="icon-plus"></i> Add to Bill</button>
</div>
</li>
<li style="display: none;">
<div class="friend-container">