Skip to content

Instantly share code, notes, and snippets.

View chanakasan's full-sized avatar

Chanaka Abeysinghe chanakasan

View GitHub Profile
<?php
/**
* Take a string_like_this and return a StringLikeThis
*
* @param string
* @return string
*/
function _snakeToCamel($val) {
return str_replace(' ', '', ucwords(str_replace('_', ' ', $val)));
}
<?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
{
<?xml version="1.0" encoding="UTF-8"?>
<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit bootstrap = "../../../../app/bootstrap.php.cache"
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
<?php
/**
* Simple excel writer class with no external dependencies, drop it in and have fun
* @author Matt Nowack
* @license Unlicensed
* @version 1.0
*/
class Excel {
private $col;
@chanakasan
chanakasan / salt-generate.php
Last active December 27, 2015 11:39
php snippet for generating a random salt
<?php
$salt = base_convert(sha1(uniqid(mt_rand(), true)), 16, 36);
@chanakasan
chanakasan / FunctionalTestCase.php
Created November 6, 2013 02:31
Symfony2 FunctionalTestCase for extending integration test classes
<?php
namespace Panda86\AppBundle\Tests;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\StringInput;
class FunctionalTestCase extends WebTestCase
@chanakasan
chanakasan / error.html.twig
Created November 7, 2013 12:17
Symfony2 custom error page, (put in app\Resources\TwigBundle\views\Exception)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Page not found!</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
{% block stylesheets %}
<?php
class EmailTestCase extends PHPUnit_Framework_TestCase {
/**
* @var \Guzzle\Http\Client
*/
private $mailcatcher;
public function setUp()
{
# config.yml
fos_rest:
format_listener:
rules:
- { path: ^/, priorities: [ json, xml, html ], fallback_format: ~, prefer_extension: false }
view:
view_response_listener: force
sensio_framework_extra:
view: { annotations: false }
guard :shell do
watch(%r{^spec/.+Spec.php}) { |m|
system("clear")
system("bin/phpspec run --no-interaction --format=pretty #{m[0]}")
}
watch(%r{^src/(.+).php}) {
system("clear")
system("bin/phpspec run --no-interaction --format=pretty")
}