Skip to content

Commit 0974606

Browse files
committed
made some cleanup in tests
1 parent 0b2948f commit 0974606

16 files changed

+45
-332
lines changed

src/Symfony/Component/HttpKernel/Tests/Exception/AccessdeniedHttpExceptionTest.php

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,10 @@
44

55
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
66

7-
/**
8-
* Test the AccessDeniedHttpException class.
9-
*/
107
class AccessDeniedHttpExceptionTest extends HttpExceptionTest
118
{
12-
/**
13-
* Test that the default headers is an empty array.
14-
*/
15-
public function testHeadersDefault()
9+
protected function createException()
1610
{
17-
$exception = new AccessDeniedHttpException();
18-
$this->assertSame(array(), $exception->getHeaders());
19-
}
20-
21-
/**
22-
* Test that setting the headers using the setter function
23-
* is working as expected.
24-
*
25-
* @param array $headers The headers to set.
26-
*
27-
* @dataProvider headerDataProvider
28-
*/
29-
public function testHeadersSetter($headers)
30-
{
31-
$exception = new AccessDeniedHttpException();
32-
$exception->setHeaders($headers);
33-
$this->assertSame($headers, $exception->getHeaders());
11+
return new AccessDeniedHttpException();
3412
}
3513
}

src/Symfony/Component/HttpKernel/Tests/Exception/BadRequestHttpExceptionTest.php

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,10 @@
44

55
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
66

7-
/**
8-
* Test the BadRequestHttpException class.
9-
*/
107
class BadRequestHttpExceptionTest extends HttpExceptionTest
118
{
12-
/**
13-
* Test that the default headers is an empty array.
14-
*/
15-
public function testHeadersDefault()
9+
protected function createException()
1610
{
17-
$exception = new BadRequestHttpException();
18-
$this->assertSame(array(), $exception->getHeaders());
19-
}
20-
21-
/**
22-
* Test that setting the headers using the setter function
23-
* is working as expected.
24-
*
25-
* @param array $headers The headers to set.
26-
*
27-
* @dataProvider headerDataProvider
28-
*/
29-
public function testHeadersSetter($headers)
30-
{
31-
$exception = new BadRequestHttpException();
32-
$exception->setHeaders($headers);
33-
$this->assertSame($headers, $exception->getHeaders());
11+
return new BadRequestHttpException();
3412
}
3513
}

src/Symfony/Component/HttpKernel/Tests/Exception/ConflictHttpExceptionTest.php

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,10 @@
44

55
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
66

7-
/**
8-
* Test the ConflictHttpException class.
9-
*/
107
class ConflictHttpExceptionTest extends HttpExceptionTest
118
{
12-
/**
13-
* Test that the default headers is an empty array.
14-
*/
15-
public function testHeadersDefault()
9+
protected function createException()
1610
{
17-
$exception = new ConflictHttpException();
18-
$this->assertSame(array(), $exception->getHeaders());
19-
}
20-
21-
/**
22-
* Test that setting the headers using the setter function
23-
* is working as expected.
24-
*
25-
* @param array $headers The headers to set.
26-
*
27-
* @dataProvider headerDataProvider
28-
*/
29-
public function testHeadersSetter($headers)
30-
{
31-
$exception = new ConflictHttpException();
32-
$exception->setHeaders($headers);
33-
$this->assertSame($headers, $exception->getHeaders());
11+
return new ConflictHttpException();
3412
}
3513
}

src/Symfony/Component/HttpKernel/Tests/Exception/GoneHttpExceptionTest.php

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,10 @@
44

55
use Symfony\Component\HttpKernel\Exception\GoneHttpException;
66

7-
/**
8-
* Test the GoneHttpException class.
9-
*/
107
class GoneHttpExceptionTest extends HttpExceptionTest
118
{
12-
/**
13-
* Test that the default headers is an empty array.
14-
*/
15-
public function testHeadersDefault()
9+
protected function createException()
1610
{
17-
$exception = new GoneHttpException();
18-
$this->assertSame(array(), $exception->getHeaders());
19-
}
20-
21-
/**
22-
* Test that setting the headers using the setter function
23-
* is working as expected.
24-
*
25-
* @param array $headers The headers to set.
26-
*
27-
* @dataProvider headerDataProvider
28-
*/
29-
public function testHeadersSetter($headers)
30-
{
31-
$exception = new GoneHttpException();
32-
$exception->setHeaders($headers);
33-
$this->assertSame($headers, $exception->getHeaders());
11+
return new GoneHttpException();
3412
}
3513
}

src/Symfony/Component/HttpKernel/Tests/Exception/HttpExceptionTest.php

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,8 @@
44

55
use Symfony\Component\HttpKernel\Exception\HttpException;
66

7-
/**
8-
* Test the HttpException class.
9-
*/
107
class HttpExceptionTest extends \PHPUnit_Framework_TestCase
118
{
12-
/**
13-
* Provides header data for the tests.
14-
*
15-
* @return array
16-
*/
179
public function headerDataProvider()
1810
{
1911
return array(
@@ -28,21 +20,13 @@ public function headerDataProvider()
2820
);
2921
}
3022

31-
/**
32-
* Test that the default headers is an empty array.
33-
*/
3423
public function testHeadersDefault()
3524
{
36-
$exception = new HttpException(200);
25+
$exception = $this->createException();
3726
$this->assertSame(array(), $exception->getHeaders());
3827
}
3928

4029
/**
41-
* Test that setting the headers using the constructor parameter
42-
* is working as expected.
43-
*
44-
* @param array $headers The headers to set.
45-
*
4630
* @dataProvider headerDataProvider
4731
*/
4832
public function testHeadersConstructor($headers)
@@ -52,17 +36,17 @@ public function testHeadersConstructor($headers)
5236
}
5337

5438
/**
55-
* Test that setting the headers using the setter function
56-
* is working as expected.
57-
*
58-
* @param array $headers The headers to set.
59-
*
6039
* @dataProvider headerDataProvider
6140
*/
6241
public function testHeadersSetter($headers)
6342
{
64-
$exception = new HttpException(200);
43+
$exception = $this->createException();
6544
$exception->setHeaders($headers);
6645
$this->assertSame($headers, $exception->getHeaders());
6746
}
47+
48+
protected function createException()
49+
{
50+
return new HttpException(200);
51+
}
6852
}

src/Symfony/Component/HttpKernel/Tests/Exception/LengthRequiredHttpExceptionTest.php

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,10 @@
44

55
use Symfony\Component\HttpKernel\Exception\LengthRequiredHttpException;
66

7-
/**
8-
* Test the LengthRequiredHttpException class.
9-
*/
107
class LengthRequiredHttpExceptionTest extends HttpExceptionTest
118
{
12-
/**
13-
* Test that the default headers is an empty array.
14-
*/
15-
public function testHeadersDefault()
9+
protected function createException()
1610
{
17-
$exception = new LengthRequiredHttpException();
18-
$this->assertSame(array(), $exception->getHeaders());
19-
}
20-
21-
/**
22-
* Test that setting the headers using the setter function
23-
* is working as expected.
24-
*
25-
* @param array $headers The headers to set.
26-
*
27-
* @dataProvider headerDataProvider
28-
*/
29-
public function testHeadersSetter($headers)
30-
{
31-
$exception = new LengthRequiredHttpException();
32-
$exception->setHeaders($headers);
33-
$this->assertSame($headers, $exception->getHeaders());
11+
return new LengthRequiredHttpException();
3412
}
3513
}

src/Symfony/Component/HttpKernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,15 @@
44

55
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
66

7-
/**
8-
* Test the MethodNotAllowedHttpException class.
9-
*/
107
class MethodNotAllowedHttpExceptionTest extends HttpExceptionTest
118
{
12-
/**
13-
* Test that the default headers is set as expected.
14-
*/
159
public function testHeadersDefault()
1610
{
1711
$exception = new MethodNotAllowedHttpException(array('GET', 'PUT'));
1812
$this->assertSame(array('Allow' => 'GET, PUT'), $exception->getHeaders());
1913
}
2014

2115
/**
22-
* Test that setting the headers using the setter function
23-
* is working as expected.
24-
*
25-
* @param array $headers The headers to set.
26-
*
2716
* @dataProvider headerDataProvider
2817
*/
2918
public function testHeadersSetter($headers)

src/Symfony/Component/HttpKernel/Tests/Exception/NotAcceptableHttpExceptionTest.php

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,10 @@
44

55
use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
66

7-
/**
8-
* Test the NotAcceptableHttpException class.
9-
*/
107
class NotAcceptableHttpExceptionTest extends HttpExceptionTest
118
{
12-
/**
13-
* Test that the default headers is an empty array.
14-
*/
15-
public function testHeadersDefault()
9+
protected function createException()
1610
{
17-
$exception = new NotAcceptableHttpException();
18-
$this->assertSame(array(), $exception->getHeaders());
19-
}
20-
21-
/**
22-
* Test that setting the headers using the setter function
23-
* is working as expected.
24-
*
25-
* @param array $headers The headers to set.
26-
*
27-
* @dataProvider headerDataProvider
28-
*/
29-
public function testHeadersSetter($headers)
30-
{
31-
$exception = new NotAcceptableHttpException();
32-
$exception->setHeaders($headers);
33-
$this->assertSame($headers, $exception->getHeaders());
11+
return new NotAcceptableHttpException();
3412
}
3513
}

src/Symfony/Component/HttpKernel/Tests/Exception/NotFoundHttpExceptionTest.php

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,10 @@
44

55
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
66

7-
/**
8-
* Test the NotFoundHttpException class.
9-
*/
107
class NotFoundHttpExceptionTest extends HttpExceptionTest
118
{
12-
/**
13-
* Test that the default headers is an empty array.
14-
*/
15-
public function testHeadersDefault()
9+
protected function createException()
1610
{
17-
$exception = new NotFoundHttpException();
18-
$this->assertSame(array(), $exception->getHeaders());
19-
}
20-
21-
/**
22-
* Test that setting the headers using the setter function
23-
* is working as expected.
24-
*
25-
* @param array $headers The headers to set.
26-
*
27-
* @dataProvider headerDataProvider
28-
*/
29-
public function testHeadersSetter($headers)
30-
{
31-
$exception = new NotFoundHttpException();
32-
$exception->setHeaders($headers);
33-
$this->assertSame($headers, $exception->getHeaders());
11+
return new NotFoundHttpException();
3412
}
3513
}

src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,10 @@
44

55
use Symfony\Component\HttpKernel\Exception\PreconditionFailedHttpException;
66

7-
/**
8-
* Test the PreconditionFailedHttpException class.
9-
*/
107
class PreconditionFailedHttpExceptionTest extends HttpExceptionTest
118
{
12-
/**
13-
* Test that the default headers is an empty array.
14-
*/
15-
public function testHeadersDefault()
9+
protected function createException()
1610
{
17-
$exception = new PreconditionFailedHttpException();
18-
$this->assertSame(array(), $exception->getHeaders());
19-
}
20-
21-
/**
22-
* Test that setting the headers using the setter function
23-
* is working as expected.
24-
*
25-
* @param array $headers The headers to set.
26-
*
27-
* @dataProvider headerDataProvider
28-
*/
29-
public function testHeadersSetter($headers)
30-
{
31-
$exception = new PreconditionFailedHttpException();
32-
$exception->setHeaders($headers);
33-
$this->assertSame($headers, $exception->getHeaders());
11+
return new PreconditionFailedHttpException();
3412
}
3513
}

0 commit comments

Comments
 (0)