for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Ternary Operators Sniff test file
*
* @package PHPCompatibility
*/
* Ternary Operators Sniff tests
* @uses BaseSniffTest
* @author Jansen Price <[email protected]>
class TernaryOperatorsSniffTest extends BaseSniffTest
{
* Sniffed file
* @var PHP_CodeSniffer_File
protected $_sniffFile;
* setUp
* @return void
public function setUp()
parent::setUp();
}
* Test ternary operators that are acceptable in all PHP versions.
public function testStandardTernaryOperators()
$this->_sniffFile = $this->sniffFile('sniff-examples/ternary_operator.php');
$this->assertNoViolation($this->_sniffFile, 5);
* 5.2 doesn't support elvis operator.
public function testMissingMiddleExpression5dot2()
$this->_sniffFile = $this->sniffFile('sniff-examples/ternary_operator.php', '5.2');
$this->assertWarning($this->_sniffFile, 8,
"Middle may not be omitted from ternary operators in PHP < 5.3");
* 5.3 does support elvis operator.
public function testMissingMiddleExpression5dot3()
$this->_sniffFile = $this->sniffFile('sniff-examples/ternary_operator.php', '5.3');
$this->assertNoViolation($this->_sniffFile, 8,