Skip to content

Instantly share code, notes, and snippets.

View DavertMik's full-sized avatar
🤓
developing codeception & codeceptjs

Michael Bodnarchuk DavertMik

🤓
developing codeception & codeceptjs
View GitHub Profile
=ashSJHDAKSJdaksd=
@DavertMik
DavertMik / gist:1844158
Created February 16, 2012 11:18
Extending specifications
<?php
$I = new WebGuy();
$I->am('regular site user'); // As a regular user
$I->wantTo('create my blog page'); // I want to create my blog page
$I->lookForwardTo('get a cool blog here'); // So that I gain a cool blog
$I->createBlog('my first blog');
$I->see('My first blog', 'h1');
$I->seeInCurrentUrl('blog/my-first-blog');
@DavertMik
DavertMik / gist:1862951
Created February 19, 2012 10:14
Codeception Spec BDD
<?php
class EventMachineCest {
// Thus, a BDD goes this way:
// create a Cest class
// define features with should* methods
// define specifications in methods
// use wantTo or expect to define wider descriptions.
// use @doc annotations to assign this scenario to method in documentation.
@DavertMik
DavertMik / gist:1934769
Created February 28, 2012 20:04
Global Object Access
<?php
class Controller implements RequestAccess, ResponseAccess, SessionAccess {
function getRequest()
{
Registry::get('request', $this);
}
function getResponse()
@DavertMik
DavertMik / gist:1936860
Created February 29, 2012 01:40
Dependency Management Concept. RFC

This is about getting rid of Dependency Injection Container and DI practices taken from Java. Good bye Java, viva la PHP!

We start with common example. Session.

<?php

class SessionStorage {

 	function __construct() 
<?php
# it's a template
class BaseStorage extends %storage% {
}
# it's a class
@DavertMik
DavertMik / gist:2041039
Created March 15, 2012 01:30
Slicework with Symfony2

Slivework is a new metaframework which aims to share functinality through different PHP frameworks. It takes business logic from controller to service classes. The service layer leaves all http processing to current framework and moves all business into it. Controllers are forbidden to access database directly, all db operations is passed to service. Sliceworks uses Doctrine ORM + ODM.

Slicework in Symfony 2

  1. Each slice is a Symfony2 bundle

src/Slicework/UserBundle/ src/Slicework/UserMessagingBundle/ src/Slicework/UserInvitesBundle/ ....

@DavertMik
DavertMik / gist:2836634
Created May 30, 2012 14:23
Codeception Soap Request Definition RFC
$soap->survey
->set('id', $survey_id)
->questions->item
->set('id', $question_id);
->answers->item
->set('id', $answer_id)
->attributes->item
->set('id', 1)
->set('value', 123);
->parent('answers') // back to answers element
@DavertMik
DavertMik / Описание
Created May 30, 2012 14:56
Codeception SOAP Suite RFC
<?php
use \Codeception\Utils\Soap;
$I = new ApiGuy($scenario);
$I->wantTo('get all unpassed surveys');
$I->haveSoapHeader('AuthHeader', array(), 'ns');
$I->haveSoapHeader('SessionHeader', array(), 'ns');
$I->sendSoapRequest('GetRespondentConsentForm', Soap::request()
->survey
->set('id', $survey_id)
<?php
$I = new WebGuy($scenario);
$I->wantTo('register on site and sign in');
$I->click('Register');
$I->fillField('Username','MilesDavis');
$I->fillField('Email','miles2@davis.com');
$I->click('Next');
$generatedPass = $I->grabTextFrom('#password');
$I->click('Login');
$I->fillField('Username','MilesDavis');