浏览代码

Use setExpectedException in tests

core23 8 年之前
父节点
当前提交
ab4f43c34a
共有 1 个文件被更改,包括 10 次插入15 次删除
  1. 10 15
      Tests/Filter/FilterFactoryTest.php

+ 10 - 15
Tests/Filter/FilterFactoryTest.php

@@ -15,55 +15,50 @@ use Sonata\AdminBundle\Filter\FilterFactory;
 
 class FilterFactoryTest extends \PHPUnit_Framework_TestCase
 {
-    /**
-     * @expectedException RuntimeException
-     */
     public function testEmptyType()
     {
+        $this->setExpectedException('\RuntimeException', 'The type must be defined');
+
         $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
 
         $filter = new FilterFactory($container, array());
         $filter->create('test', null);
     }
 
-    /**
-     * @expectedException RuntimeException
-     */
     public function testUnknownType()
     {
+        $this->setExpectedException('\RuntimeException', 'No attached service to type named `mytype`');
+
         $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
 
         $filter = new FilterFactory($container, array());
         $filter->create('test', 'mytype');
     }
 
-    /**
-     * @expectedException RuntimeException
-     */
     public function testUnknownClassType()
     {
+        $this->setExpectedException('\RuntimeException', 'No attached service to type named `Sonata\AdminBundle\Form\Type\Filter\FooType`');
+
         $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
 
         $filter = new FilterFactory($container, array());
         $filter->create('test', 'Sonata\AdminBundle\Form\Type\Filter\FooType');
     }
 
-    /**
-     * @expectedException RuntimeException
-     */
     public function testClassType()
     {
+        $this->setExpectedException('\RuntimeException', 'The service `Sonata\AdminBundle\Form\Type\Filter\DefaultType` must implement `FilterInterface`');
+
         $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
 
         $filter = new FilterFactory($container, array());
         $filter->create('test', 'Sonata\AdminBundle\Form\Type\Filter\DefaultType');
     }
 
-    /**
-     * @expectedException RuntimeException
-     */
     public function testInvalidTypeInstance()
     {
+        $this->setExpectedException('\RuntimeException', 'The service `mytype` must implement `FilterInterface`');
+
         $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
         $container->expects($this->once())
             ->method('get')