Skip to content

Instantly share code, notes, and snippets.

View jakzal's full-sized avatar

Jakub Zalas jakzal

View GitHub Profile
@jakzal
jakzal / SearchPage.php
Created February 8, 2019 15:28
Page objects
<?php declare(strict_types=1);
use Behat\Mink\Element\NodeElement;
use Behat\Mink\Session;
use Zalas\PageObject\Annotation\FindBy;
use Zalas\PageObject\Annotation\MinkSession;
class SearchPage
{
/**
@jakzal
jakzal / DoublesTest.php
Last active September 26, 2018 23:22
Test double examples
<?php declare(strict_types=1);
namespace App\Tests\Doubles;
use PHPUnit\Framework\TestCase;
class Item
{
}
@jakzal
jakzal / MockerTest.php
Last active July 27, 2018 13:16
[Idea] Automated injection of test doubles into phpunit test cases
<?php
declare(strict_types=1);
namespace Zalas\Injector\Tests\Service;
use PHPUnit\Framework\TestCase;
use Prophecy\Prophecy\ObjectProphecy;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
use Zalas\Injector\PHPUnit\TestCase\ServiceContainerTestCase;
@jakzal
jakzal / keybase.md
Created June 12, 2018 17:09
keybase.md

Keybase proof

I hereby claim:

  • I am jakzal on github.
  • I am jakubzalas (https://keybase.io/jakubzalas) on keybase.
  • I have a public key ASDymt67mEWq_8pwxEXefRL4POa25z_680ovmggZWKTKHQo

To claim this, I am signing this object:

@jakzal
jakzal / DataSet.php
Created June 12, 2018 09:18
Execute your markdown specs
<?php
declare(strict_types=1);
namespace Zalas\Test\MarkdownSpec;
class DataSet implements \IteratorAggregate
{
/**
* @var array
*/
@jakzal
jakzal / war.sc
Last active May 14, 2018 07:51
War Card Game in Scala
sealed trait Suit
sealed case class Hearts() extends Suit {
override def toString = "♡"
}
sealed case class Diamonds() extends Suit {
override def toString = "♢"
}
sealed case class Clubs() extends Suit {
override def toString = "♧"
}
@jakzal
jakzal / SymfonyKernel.php
Created March 2, 2018 14:25
Replacement for Symfony's KernelTestCase
<?php
declare(strict_types=1);
namespace Zalas\PHPUnit\Injector\Symfony\TestCase;
use Symfony\Component\DependencyInjection\ResettableContainerInterface;
use Symfony\Component\HttpKernel\KernelInterface;
/**
* Mimics the behaviour of Symfony's KernelTestCase.
@jakzal
jakzal / flat_map.php
Last active July 28, 2021 16:16
Flat map in PHP
<?php
function flat_map(callable $callback, array $collection) {
return array_merge([], ...array_map($callback, $collection));
};
@jakzal
jakzal / ExampleTest.php
Last active September 23, 2020 12:23
Set global variables with PHPUnit test method annotations
<?php
declare(strict_types=1);
namespace Zalas\Tests;
use PHPUnit\Framework\TestCase;
class ExampleTest extends TestCase
{
/**
@jakzal
jakzal / QueueScraperTest.php
Last active September 28, 2022 14:55
RabbitMQ integration test
<?php
namespace Zalas\Infrastructure\Scraper;
use OldSound\RabbitMqBundle\RabbitMq\Consumer;
use OldSound\RabbitMqBundle\RabbitMq\ConsumerInterface;
use OldSound\RabbitMqBundle\RabbitMq\ProducerInterface;
use PhpAmqpLib\Connection\AbstractConnection;
use PhpAmqpLib\Connection\AMQPLazyConnection;
use PhpAmqpLib\Exception\AMQPTimeoutException;