Skip to content

Instantly share code, notes, and snippets.

@everzet
Created December 14, 2010 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save everzet/740190 to your computer and use it in GitHub Desktop.
Save everzet/740190 to your computer and use it in GitHub Desktop.
Explanation in examples why PHP will never have RSpec-like behavioral unit tests
# RSpec (aka "Best in Ruby"):
@account.balance.should == 12
# PHPUnit (aka "Best in PHP"):
$this->assertEquals(12, $account->getBalance());
# PHPSpec:
$this->spec($account->getBalance())->should->be(12);
# Fabulous:
$w->valueOf($account->getBalance())->shouldBeEqualsTo(12);
# 1. Core difference here is in `$w->valueOf(...)` & `$this->spec(...)`.
# PHP doesn't have object inheritance, like Ruby or Java, so we
# need to wrap testing variables inside `spec` or `valueOf`
# 2. Second is `.` vs `->`. At the first, they looks the same, but
# in reality:
@account.balance.should...
# is way more human-readable plain text, than:
$account->balance->should...
@marijn
Copy link

marijn commented Dec 14, 2010

I think .feature files are way more readable ;-)

@everzet
Copy link
Author

everzet commented Dec 14, 2010

Yes they are +)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment