dsyph3r / symblog-docs

Tutorial for symblog - Creating a blog in Symfony2
http://tutorial.symblog.co.uk
105 stars 78 forks source link

PHPUnit #10

Closed jaimesuez closed 12 years ago

jaimesuez commented 12 years ago

I get the following error in the Testing Part:

There was 1 error:

1) Blogger\BlogBundle\Tests\Twig\Extensions\BloggerBlogExtensionTest::testCreatedAgo
InvalidArgumentException: You must not expect the generic exception class.

/Users/jaimesuez/Sites/symblog/src/Blogger/BlogBundle/Tests/Twig/Extensions/BloggerBlogExtensionTest.php:23

FAILURES!
Tests: 4, Assertions: 14, Errors: 1.

It's related to this part of the BloggerBlogExtension.php:

<?php
// src/Blogger/BlogBundle/Tests/Twig/Extensions/BloggerBlogExtensionTest.php

namespace Blogger\BlogBundle\Tests\Twig\Extensions;

use Blogger\BlogBundle\Twig\Extensions\BloggerBlogExtension;

class BloggerBlogExtensionTest extends \PHPUnit_Framework_TestCase
{
    public function testCreatedAgo()
    {

        //....

        // Cannot create time in the future
        $this->setExpectedException('\Exception');
        $blog->createdAgo($this->getDateTime(60));
    }

Thanks!

dsyph3r commented 12 years ago

Hey, Looks like in more recent versions of PHPUnit you cannot throw just a normal Exception anymore. I have updated the createdAgo and its unit test to throw an InvalidArgumentException. See the last 2 commits

https://github.com/dsyph3r/symblog-docs/commit/fc312ebad6d365e1b5a383291e59cb2129bf178c

https://github.com/dsyph3r/symblog-docs/commit/fc312ebad6d365e1b5a383291e59cb2129bf178c

jaimesuez commented 12 years ago

Thanks!