|
| 1 | +--- |
| 2 | +title: Codecepion 1.5.2 |
| 3 | +layout: post |
| 4 | +date: 2013-01-21 01:03:50 |
| 5 | +--- |
| 6 | + |
| 7 | +Yet another minor release. It introduces more compact form for unit tests. |
| 8 | + |
| 9 | +{% highlight php %} |
| 10 | +<?php |
| 11 | +use Codeception\Util\Stub; |
| 12 | +
|
| 13 | +class UserRepositoryTest extends Codeception\TestCase\Test |
| 14 | +{ |
| 15 | + protected function _before() |
| 16 | + { |
| 17 | + $this->user = new User(); |
| 18 | + } |
| 19 | + |
| 20 | + public function testUserIsNotAdmin() |
| 21 | + { |
| 22 | + $this->assertFalse($user->isAdmin()); |
| 23 | + } |
| 24 | + |
| 25 | +} |
| 26 | +?> |
| 27 | +{% endhighlight%} |
| 28 | + |
| 29 | +We moved all Codeception's setUp and tearDown routine into parrent class and left you more clean `_before` and `_after` methods for your preperations. |
| 30 | +They act just the same as `setUp` and `tearDown` for PHPUnit. So `_before` is executed before each test and `_after` after it. |
| 31 | +Tests should look more clean now. If your tests already have setUp and tearDown methods nothing is changed for them. |
| 32 | + |
| 33 | +### Accessing Modules in Unit Tests |
| 34 | + |
| 35 | +Another nice feature for Symfony2 users and not only them. Form now on you can access a module from your unit test. |
| 36 | +This is done to access public properties of your module. For example, here is how you can retrieve a **Symfony Dependency Injection Container**: |
| 37 | + |
| 38 | +{% highlight php %} |
| 39 | +<?php |
| 40 | +protected function _before() |
| 41 | +{ |
| 42 | + /** |
| 43 | + * @var $container Symfony\Component\DependencyInjection\Container |
| 44 | + */ |
| 45 | + $container = $this->getModule('Symfony2')->container; |
| 46 | + $this->em = $container->get('doctrine'); |
| 47 | +} |
| 48 | +?> |
| 49 | +{% endhighlight%} |
| 50 | + |
| 51 | +Also we'd like to announce the upcoming modules for **Yii** and **Laravel** frameworks. |
| 52 | + |
| 53 | +In the meantime we will release more complete guides on How to integrate framework to Codeception. |
| 54 | + |
| 55 | +### Bugfixes |
| 56 | + |
| 57 | +* Composer build is finally is stable and doesn't require `minimal-stability: dev`. Thanks to: [jacobkiers](https://github.com/jacobkiers). |
| 58 | +* Adding support of `pecl_http` by [phpcodemonkey](https://github.com/phpcodemonkey). |
| 59 | +* Methods of Guy received documentation and examples (phar bug). |
| 60 | +* `generate:cest` command requires a tested class name no more. |
| 61 | +* [PostgreSQL](https://github.com/Codeception/Codeception/issues/117) driver improved . |
| 62 | + |
| 63 | +### Update |
| 64 | + |
| 65 | + [redownload](http://codeception.com/thanks.html) your `codeception.phar` for update: |
| 66 | + |
| 67 | +{% highlight bash %} |
| 68 | +wget http://codeception.com/codecept.phar -O codecept.phar |
| 69 | +{% endhighlight %} |
| 70 | + |
| 71 | +for composer version |
| 72 | + |
| 73 | +{% highlight bash %} |
| 74 | +$ php composer.phar update |
| 75 | +{% endhighlight %} |
| 76 | + |
| 77 | +or via PEAR: |
| 78 | + |
| 79 | +{% highlight bash %} |
| 80 | +$ pear install codeception/Codeception |
| 81 | +{% endhighlight %} |
| 82 | + |
| 83 | + |
0 commit comments