Skip to content

Instantly share code, notes, and snippets.

View wowo's full-sized avatar

Wojciech Sznapka wowo

View GitHub Profile
@wowo
wowo / ModelTestCase.php
Created June 14, 2011 21:26
Model Test Case, which loads fixtures and builds database before each test
<?php
require_once(__DIR__ . "/../../../../app/AppKernel.php");
class ModelTestCase extends \PHPUnit_Framework_TestCase
{
protected $_application;
public function getContainer()
{
@wowo
wowo / config_test.yml
Created June 14, 2011 21:28
Doctrine sqlite in memory for tests purposes
doctrine:
dbal:
driver: pdo_sqlite
path: :memory:
memory: true
orm:
auto_generate_proxy_classes: true
auto_mapping: true
#Dodajemy w routing.yml
tickets:
type: rest
resource: Xs\TicketingBundle\Controller\TicketsController
#Pobieranie ticketów metodą GET
/tickets -> function getTicketsAction() {...}
#Tworzenie ticketa metodą POST
/tickets -> function postTicketsAction() {...}
@wowo
wowo / OriginCall.php
Created September 26, 2011 22:25
Closure logger from Symfony2 command
<?php
class SendMailingCommand extends ContainerAwareCommand
{
protected function execute(InputInterface $input, OutputInterface $output)
{
$logger = function($message) use ($output)
{
$output->writeln($message);
};
@wowo
wowo / closureHandlling.php
Created September 26, 2011 22:29
Closure wrapper handling
<?php
class NewsletterManager implements NewsletterManagerInterface
{
public function getJobFromQueueAndSendMailing(\Closure $logger, $verbose)
{
// [...]
if ($verbose) {
$logger(sprintf("Sent message:\n%s", $message->toString()));
}
}
<?php
class MailingType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('body', 'textarea', array('class' => 'tinymce')); // it won't work!
}
}
{% form_theme form _self %}
{% block _wowo_bundle_newsletterbundle_newslettertype_mailing_body_widget %}
{{ form_widget(form, { 'attr': {'class': 'tinymce'}}) }}
{% endblock %}
<form action="" method="post" {{ form_enctype(form) }} >
{{ form_widget(form) }}
<input type="submit" value="{% trans %}Send mailing{% endtrans %}"/>
</form>
<?php
class MailingType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
//this is ain't documented but it works! :-)
$builder
->add('body', 'textarea',
array('attr' => array('class' => 'tinymce')));
}
<?php
// [...]
$loader->registerNamespaces(array(
// [...]
'lapistano' => __DIR__.'/../vendor/proxy-object/src/lapistano',
));
// [...]
// this one's important! you need it only with PHPUnit, so there's a condition
if (class_exists('PHPUnit_Runner_Version')) {
[Proxy-Object]
git=https://github.com/lapistano/proxy-object.git
target=/proxy-object