[Console][TableStyle] validate padding type value.
This commit is contained in:
parent
d7870a2b5d
commit
755653d561
@ -234,6 +234,10 @@ class TableStyle
|
|||||||
*/
|
*/
|
||||||
public function setPadType($padType)
|
public function setPadType($padType)
|
||||||
{
|
{
|
||||||
|
if (!in_array($padType, array(STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH), true)) {
|
||||||
|
throw new \InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).');
|
||||||
|
}
|
||||||
|
|
||||||
$this->padType = $padType;
|
$this->padType = $padType;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Console\Tests\Helper;
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Helper\TableStyle;
|
||||||
|
|
||||||
|
class TableStyleTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @expectedException \InvalidArgumentException
|
||||||
|
* @expectedExceptionMessage Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).
|
||||||
|
*/
|
||||||
|
public function testSetPadTypeWithInvalidType()
|
||||||
|
{
|
||||||
|
$style = new TableStyle();
|
||||||
|
$style->setPadType('TEST');
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user