Skip to content

Instantly share code, notes, and snippets.

<?php
include_once dirname(__FILE__) . '/../support/enviromment.php';
// @TODO: excluir depois feito so para testar reflexão em metodos privvados
class Foo {
private function myPrivateMethod() {
return 'blah';
}
}
# behat.yml
default:
formatter:
name: 'pretty'
#Available formats are:
#- pretty: Prints the feature as is.
#- progress: Prints one character per step.
#- html: Generates a nice looking HTML report.
#- junit: Generates a report similar to Ant+JUnit.
context:
<?php
use Behat\Behat\Context\ClosuredContextInterface,
Behat\Behat\Context\TranslatedContextInterface,
Behat\Behat\Context\BehatContext,
Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode,
Behat\Gherkin\Node\TableNode;
# features/auth_twitter.feature
Feature: Authorization on Twitter
In order to use application administration
As a user of system
I need to be able of authetication with my twitter account
@javascript
Scenario: Not Authorizing account with twitter
Given I am on "session/twitter"
And I should see "Sau Online"
@fabriziomachado
fabriziomachado / gist:1305832
Created October 22, 2011 09:59
nested_forms_test_passing
context "create questions and answers for the exam" do
let(:build_object) { mock().as_null_object }
it "should instantiate at least 3 questions" do
exam_questions = mock("questions for an exam").as_null_object
Exam.any_instance.stub(:questions).and_return(exam_questions)
exam_questions.stub(:build).and_return(build_object)
exam_questions.should_receive(:build).exactly(3).times
get :new
@fabriziomachado
fabriziomachado / AccountTest.php
Created October 20, 2011 12:25
tests/models/AccountTest.php
<?php
include_once dirname(__FILE__) . '/../support/enviromment.php';
/**
* @group models
*/
class AccountTest extends CIUnit_TestCase
{
protected $tables = array(
@fabriziomachado
fabriziomachado / Account.php
Created October 20, 2011 12:22
application/models/Account.php
<?php
class Account extends ActiveRecord\Model {
static $belongs_to = array(
array('person')
);
static $validates_inclusion_of = array(
array('provider', 'in' => array('twitter','facebook'),
<?php
/**
* @group Helper
*/
class PartialsHelperTest extends CIUnit_TestCase
{
public function setUp()
{
@fabriziomachado
fabriziomachado / Student.php
Created September 26, 2011 20:10
application/models/Student.php
<?php
class Student extends Person {
static $primary_key = 'id';
static $has_many = array(array('enrollments'));
public function __construct(array $attributes = array()) {
parent::__construct(array_merge($attributes,array('type'=> __CLASS__ )));
}
}
@fabriziomachado
fabriziomachado / .watchr.rb
Created September 26, 2011 19:03
autotest
require "open3"
watch("application/(models|controllers)/(.*).php") do |match|
test_changed_application(match[0])
end
watch("tests/(.*/.*)\.php") do |match|
phpunit match[0]
end