Skip to content

Instantly share code, notes, and snippets.

@sparrow
Created September 27, 2016 13:26
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 sparrow/5f8787d239a891ccb79aba017dbb0f8b to your computer and use it in GitHub Desktop.
Save sparrow/5f8787d239a891ccb79aba017dbb0f8b to your computer and use it in GitHub Desktop.
This is an PHPUnit code snippet that we used for our blog post https://rubygarage.org/blog/ruby-on-rails-and-symfony-comparison at RubyGarage. It demonstrates how to create a namespace with PHPUnit. This code snippet was taken from the Symfony main website.
<?php
// tests/AppBundle/Util/CalculatorTest.php
namespace Tests\AppBundle\Util;
use AppBundle\Util\Calculator;
class CalculatorTest extends \PHPUnit_Framework_TestCase
{
public function testAdd()
{
$calc = new Calculator();
$result = $calc->add(30, 12);
//assert that your calculator added the numbers correctly!
$this->assertEquals(42, $result);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment