Skip to content

Instantly share code, notes, and snippets.

View danielpotthast's full-sized avatar

Daniel Potthast danielpotthast

View GitHub Profile
<?php
class Mailer
{
private $fromEmail;
private $fromName;
private $header;
public function __construct($fromEmail, $fromName, $header)
{
class data
{
private $data;
public function __construct($data)
{
$this->data = $data;
}
public function get()
class ProductList
{
private $products = [];
public function __construct(array $productList)
{
foreach ($productList as $product) {
$this->addProduct($product);
}
}
<?php
class ProductListTest extends \PHPUnit_Framework_TestCase
{
public function testProductList()
{
$listedProduct = $this->prophesize(ProductListInterface::class);
$listedProduct->isListed()->willReturn(true);
$notListedProduct = $this->prophesize(ProductListInterface::class);
$notListedProduct->isListed()->willReturn(false);
<?php
namespace Demo;
interface ProductListInterface
{
/**
* Checks if the product is listed.
*
* @return bool
<?php
namespace Demo;
class ProductList
{
}
<?php
namespace Tests\Demo;
use Demo\ProductList;
class ProductListTest extends \PHPUnit_Framework_TestCase
{
public function testProductList()
{
<?php
class data
{
private $data;
public function __construct($data)
{
$this->data = $data;
}
self.addEventListener("fetch", (event) => {
event.respondWith(
caches.match(event.request)
.then(response => {
if (response) {
return response;
}
// Version #1: Cache all (!) responses and return error page
// Clone the request
// Cleanup old cache storages
self.addEventListener("activate", event => {
event.waitUntil(
caches.keys()
.then(cacheNames => {
return Promise.all(
cacheNames.map(cacheName => {
if (CACHE_VERSION !== cacheName) {
return caches.delete(cacheName);
}