Skip to content

Instantly share code, notes, and snippets.

View yupe's full-sized avatar
🤔

Yupe! team yupe

🤔
View GitHub Profile
@yupe
yupe / php-storm-format
Created September 14, 2011 13:14
До
$comment->setAttributes(array(
'userId' => Yii::app()->user->getId(),
'name' => Yii::app()->user->getState('nickName'),
'email' => Yii::app()->user->getState('email'),
));
@yupe
yupe / php-storm-format-after
Created September 14, 2011 13:15
после
$comment->setAttributes(array(
'userId' => Yii::app()->user->getId(),
'name' => Yii::app()->user->getState('nickName'),
'email' => Yii::app()->user->getState('email'),
));
use strict;
use warnings;
use 5.010;
use Data::Dumper;
use Mojo::UserAgent;
use Mojo::JSON;
my $user = 'xomaa';
my $url = "https://api.twitter.com/1/favorites.json?count=3&include_entities=1&id=$user";
my $ua = Mojo::UserAgent->new;
<?php
/**
* Craft by Pixel & Tonic
*
* @package Craft
* @author Pixel & Tonic, Inc.
* @copyright Copyright (c) 2013, Pixel & Tonic, Inc.
* @license http://buildwithcraft.com/license Craft License Agreement
* @link http://buildwithcraft.com
<?php
$I = new WebGuy($scenario);
$I->wantTo('Test "contact" page of amyLabs site!');
$I->amOnPage('/contact');
// check title
$I->see('Наши контакты','h2');
// check contact information
foreach ($contacts as $contact){
@yupe
yupe / gist:6547244
Created September 13, 2013 06:21
А вот так тесты писать приятнее +) Codeception рулит =)
<?php
use \WebGuy;
class UserLoginCest
{
public function testLoginPage(WebGuy $I) {
$I->amOnPage('/user/account/login');
$I->seeInTitle('Войти');
$I->seeLink('Забыли пароль?');
$I->see('Войти');
<?php
namespace tests\_pages\user;
use yii\codeception\BasePage;
class LoginPage extends BasePage
{
public $route = 'account/login';
public function publish()
{
$transaction = Yii::app()->db->beginTransaction();
try
{
$this->status = self::STATUS_PUBLISHED;
$this->publish_date = date('d-m-Y h:i');
if($this->save()) {
Yii::app()->eventManager->fire(PostEvents::POST_PUBLISH, new PostPublishEvent($this, Yii::app()->getUser()));
@yupe
yupe / gist:8ec8e205ce7b6ce57600
Created June 5, 2014 10:47
EventDispatcher wrapper
<?php
namespace yupe\components;
use Symfony\Component\EventDispatcher\Event;
use Yii;
use CApplicationComponent;
use Symfony\Component\EventDispatcher\EventDispatcher;
class EventManager extends CApplicationComponent
{% extends "layouts/main.twig" %}
{% block title %}{{ post.title }}{% endblock %}
{% block description %}{{ post.getQuote() }}{% endblock %}
{% block keywords %}yii, yiiframework, юпи!, yupe, блог, записи{% endblock %}
{% block content %}
<section id="blog-post" class="light-bg">
<div class="container inner-top-sm inner-bottom classic-blog">