mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-27 04:24:43 +01:00
Use stricter assertions where possible
This commit is contained in:
parent
3d40e2217d
commit
66fd29cb58
@ -23,7 +23,7 @@ class InterfaceTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testEmpty() {
|
public function testEmpty() {
|
||||||
$contract = $this->builder->getNode();
|
$contract = $this->builder->getNode();
|
||||||
$this->assertInstanceOf('PhpParser\Node\Stmt\Interface_', $contract);
|
$this->assertInstanceOf('PhpParser\Node\Stmt\Interface_', $contract);
|
||||||
$this->assertEquals('Contract', $contract->name);
|
$this->assertSame('Contract', $contract->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExtending() {
|
public function testExtending() {
|
||||||
@ -41,7 +41,7 @@ class InterfaceTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testAddMethod() {
|
public function testAddMethod() {
|
||||||
$method = new Stmt\ClassMethod('doSomething');
|
$method = new Stmt\ClassMethod('doSomething');
|
||||||
$contract = $this->builder->addStmt($method)->getNode();
|
$contract = $this->builder->addStmt($method)->getNode();
|
||||||
$this->assertEquals(array($method), $contract->stmts);
|
$this->assertSame(array($method), $contract->stmts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddConst() {
|
public function testAddConst() {
|
||||||
@ -49,7 +49,7 @@ class InterfaceTest extends \PHPUnit_Framework_TestCase
|
|||||||
new Node\Const_('SPEED_OF_LIGHT', new DNumber(299792458))
|
new Node\Const_('SPEED_OF_LIGHT', new DNumber(299792458))
|
||||||
));
|
));
|
||||||
$contract = $this->builder->addStmt($const)->getNode();
|
$contract = $this->builder->addStmt($const)->getNode();
|
||||||
$this->assertEquals(299792458, $contract->stmts[0]->consts[0]->value->value);
|
$this->assertSame(299792458, $contract->stmts[0]->consts[0]->value->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOrder() {
|
public function testOrder() {
|
||||||
|
@ -7,16 +7,16 @@ class CommentTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testGetSet() {
|
public function testGetSet() {
|
||||||
$comment = new Comment('/* Some comment */', 1);
|
$comment = new Comment('/* Some comment */', 1);
|
||||||
|
|
||||||
$this->assertEquals('/* Some comment */', $comment->getText());
|
$this->assertSame('/* Some comment */', $comment->getText());
|
||||||
$this->assertEquals('/* Some comment */', (string) $comment);
|
$this->assertSame('/* Some comment */', (string) $comment);
|
||||||
$this->assertEquals(1, $comment->getLine());
|
$this->assertSame(1, $comment->getLine());
|
||||||
|
|
||||||
$comment->setText('/* Some other comment */');
|
$comment->setText('/* Some other comment */');
|
||||||
$comment->setLine(10);
|
$comment->setLine(10);
|
||||||
|
|
||||||
$this->assertEquals('/* Some other comment */', $comment->getText());
|
$this->assertSame('/* Some other comment */', $comment->getText());
|
||||||
$this->assertEquals('/* Some other comment */', (string) $comment);
|
$this->assertSame('/* Some other comment */', (string) $comment);
|
||||||
$this->assertEquals(10, $comment->getLine());
|
$this->assertSame(10, $comment->getLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,7 +24,7 @@ class CommentTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testReformatting($commentText, $reformattedText) {
|
public function testReformatting($commentText, $reformattedText) {
|
||||||
$comment = new Comment($commentText);
|
$comment = new Comment($commentText);
|
||||||
$this->assertEquals($reformattedText, $comment->getReformattedText());
|
$this->assertSame($reformattedText, $comment->getReformattedText());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provideTestReformatting() {
|
public function provideTestReformatting() {
|
||||||
|
@ -7,9 +7,9 @@ class ErrorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testConstruct() {
|
public function testConstruct() {
|
||||||
$error = new Error('Some error', 10);
|
$error = new Error('Some error', 10);
|
||||||
|
|
||||||
$this->assertEquals('Some error', $error->getRawMessage());
|
$this->assertSame('Some error', $error->getRawMessage());
|
||||||
$this->assertEquals(10, $error->getRawLine());
|
$this->assertSame(10, $error->getRawLine());
|
||||||
$this->assertEquals('Some error on line 10', $error->getMessage());
|
$this->assertSame('Some error on line 10', $error->getMessage());
|
||||||
|
|
||||||
return $error;
|
return $error;
|
||||||
}
|
}
|
||||||
@ -21,15 +21,15 @@ class ErrorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$error->setRawMessage('Some other error');
|
$error->setRawMessage('Some other error');
|
||||||
$error->setRawLine(15);
|
$error->setRawLine(15);
|
||||||
|
|
||||||
$this->assertEquals('Some other error', $error->getRawMessage());
|
$this->assertSame('Some other error', $error->getRawMessage());
|
||||||
$this->assertEquals(15, $error->getRawLine());
|
$this->assertSame(15, $error->getRawLine());
|
||||||
$this->assertEquals('Some other error on line 15', $error->getMessage());
|
$this->assertSame('Some other error on line 15', $error->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUnknownLine() {
|
public function testUnknownLine() {
|
||||||
$error = new Error('Some error');
|
$error = new Error('Some error');
|
||||||
|
|
||||||
$this->assertEquals(-1, $error->getRawLine());
|
$this->assertSame(-1, $error->getRawLine());
|
||||||
$this->assertEquals('Some error on unknown line', $error->getMessage());
|
$this->assertSame('Some error on unknown line', $error->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,8 +19,8 @@ class EmulativeTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testReplaceKeywords($keyword, $expectedToken) {
|
public function testReplaceKeywords($keyword, $expectedToken) {
|
||||||
$this->lexer->startLexing('<?php ' . $keyword);
|
$this->lexer->startLexing('<?php ' . $keyword);
|
||||||
|
|
||||||
$this->assertEquals($expectedToken, $this->lexer->getNextToken());
|
$this->assertSame($expectedToken, $this->lexer->getNextToken());
|
||||||
$this->assertEquals(0, $this->lexer->getNextToken());
|
$this->assertSame(0, $this->lexer->getNextToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,9 +29,9 @@ class EmulativeTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testNoReplaceKeywordsAfterObjectOperator($keyword) {
|
public function testNoReplaceKeywordsAfterObjectOperator($keyword) {
|
||||||
$this->lexer->startLexing('<?php ->' . $keyword);
|
$this->lexer->startLexing('<?php ->' . $keyword);
|
||||||
|
|
||||||
$this->assertEquals(Parser::T_OBJECT_OPERATOR, $this->lexer->getNextToken());
|
$this->assertSame(Parser::T_OBJECT_OPERATOR, $this->lexer->getNextToken());
|
||||||
$this->assertEquals(Parser::T_STRING, $this->lexer->getNextToken());
|
$this->assertSame(Parser::T_STRING, $this->lexer->getNextToken());
|
||||||
$this->assertEquals(0, $this->lexer->getNextToken());
|
$this->assertSame(0, $this->lexer->getNextToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provideTestReplaceKeywords() {
|
public function provideTestReplaceKeywords() {
|
||||||
@ -62,10 +62,10 @@ class EmulativeTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
foreach ($expectedTokens as $expectedToken) {
|
foreach ($expectedTokens as $expectedToken) {
|
||||||
list($expectedTokenType, $expectedTokenText) = $expectedToken;
|
list($expectedTokenType, $expectedTokenText) = $expectedToken;
|
||||||
$this->assertEquals($expectedTokenType, $this->lexer->getNextToken($text));
|
$this->assertSame($expectedTokenType, $this->lexer->getNextToken($text));
|
||||||
$this->assertEquals($expectedTokenText, $text);
|
$this->assertSame($expectedTokenText, $text);
|
||||||
}
|
}
|
||||||
$this->assertEquals(0, $this->lexer->getNextToken());
|
$this->assertSame(0, $this->lexer->getNextToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,9 +75,9 @@ class EmulativeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$stringifiedToken = '"' . addcslashes($code, '"\\') . '"';
|
$stringifiedToken = '"' . addcslashes($code, '"\\') . '"';
|
||||||
$this->lexer->startLexing('<?php ' . $stringifiedToken);
|
$this->lexer->startLexing('<?php ' . $stringifiedToken);
|
||||||
|
|
||||||
$this->assertEquals(Parser::T_CONSTANT_ENCAPSED_STRING, $this->lexer->getNextToken($text));
|
$this->assertSame(Parser::T_CONSTANT_ENCAPSED_STRING, $this->lexer->getNextToken($text));
|
||||||
$this->assertEquals($stringifiedToken, $text);
|
$this->assertSame($stringifiedToken, $text);
|
||||||
$this->assertEquals(0, $this->lexer->getNextToken());
|
$this->assertSame(0, $this->lexer->getNextToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provideTestLexNewFeatures() {
|
public function provideTestLexNewFeatures() {
|
||||||
|
@ -18,7 +18,7 @@ class LexerTest extends \PHPUnit_Framework_TestCase
|
|||||||
try {
|
try {
|
||||||
$this->lexer->startLexing($code);
|
$this->lexer->startLexing($code);
|
||||||
} catch (Error $e) {
|
} catch (Error $e) {
|
||||||
$this->assertEquals($message, $e->getMessage());
|
$this->assertSame($message, $e->getMessage());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -42,8 +42,8 @@ class LexerTest extends \PHPUnit_Framework_TestCase
|
|||||||
while ($id = $this->lexer->getNextToken($value, $startAttributes, $endAttributes)) {
|
while ($id = $this->lexer->getNextToken($value, $startAttributes, $endAttributes)) {
|
||||||
$token = array_shift($tokens);
|
$token = array_shift($tokens);
|
||||||
|
|
||||||
$this->assertEquals($token[0], $id);
|
$this->assertSame($token[0], $id);
|
||||||
$this->assertEquals($token[1], $value);
|
$this->assertSame($token[1], $value);
|
||||||
$this->assertEquals($token[2], $startAttributes);
|
$this->assertEquals($token[2], $startAttributes);
|
||||||
$this->assertEquals($token[3], $endAttributes);
|
$this->assertEquals($token[3], $endAttributes);
|
||||||
}
|
}
|
||||||
@ -131,8 +131,8 @@ class LexerTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
while (Parser::T_HALT_COMPILER !== $this->lexer->getNextToken());
|
while (Parser::T_HALT_COMPILER !== $this->lexer->getNextToken());
|
||||||
|
|
||||||
$this->assertEquals($this->lexer->handleHaltCompiler(), $remaining);
|
$this->assertSame($this->lexer->handleHaltCompiler(), $remaining);
|
||||||
$this->assertEquals(0, $this->lexer->getNextToken());
|
$this->assertSame(0, $this->lexer->getNextToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provideTestHaltCompiler() {
|
public function provideTestHaltCompiler() {
|
||||||
|
@ -6,93 +6,93 @@ class NameTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
public function testConstruct() {
|
public function testConstruct() {
|
||||||
$name = new Name(array('foo', 'bar'));
|
$name = new Name(array('foo', 'bar'));
|
||||||
$this->assertEquals(array('foo', 'bar'), $name->parts);
|
$this->assertSame(array('foo', 'bar'), $name->parts);
|
||||||
|
|
||||||
$name = new Name('foo\bar');
|
$name = new Name('foo\bar');
|
||||||
$this->assertEquals(array('foo', 'bar'), $name->parts);
|
$this->assertSame(array('foo', 'bar'), $name->parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGet() {
|
public function testGet() {
|
||||||
$name = new Name('foo');
|
$name = new Name('foo');
|
||||||
$this->assertEquals('foo', $name->getFirst());
|
$this->assertSame('foo', $name->getFirst());
|
||||||
$this->assertEquals('foo', $name->getLast());
|
$this->assertSame('foo', $name->getLast());
|
||||||
|
|
||||||
$name = new Name('foo\bar');
|
$name = new Name('foo\bar');
|
||||||
$this->assertEquals('foo', $name->getFirst());
|
$this->assertSame('foo', $name->getFirst());
|
||||||
$this->assertEquals('bar', $name->getLast());
|
$this->assertSame('bar', $name->getLast());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testToString() {
|
public function testToString() {
|
||||||
$name = new Name('foo\bar');
|
$name = new Name('foo\bar');
|
||||||
|
|
||||||
$this->assertEquals('foo\bar', (string) $name);
|
$this->assertSame('foo\bar', (string) $name);
|
||||||
$this->assertEquals('foo\bar', $name->toString());
|
$this->assertSame('foo\bar', $name->toString());
|
||||||
$this->assertEquals('foo_bar', $name->toString('_'));
|
$this->assertSame('foo_bar', $name->toString('_'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSet() {
|
public function testSet() {
|
||||||
$name = new Name('foo');
|
$name = new Name('foo');
|
||||||
|
|
||||||
$name->set('foo\bar');
|
$name->set('foo\bar');
|
||||||
$this->assertEquals('foo\bar', $name->toString());
|
$this->assertSame('foo\bar', $name->toString());
|
||||||
|
|
||||||
$name->set(array('foo', 'bar'));
|
$name->set(array('foo', 'bar'));
|
||||||
$this->assertEquals('foo\bar', $name->toString());
|
$this->assertSame('foo\bar', $name->toString());
|
||||||
|
|
||||||
$name->set(new Name('foo\bar'));
|
$name->set(new Name('foo\bar'));
|
||||||
$this->assertEquals('foo\bar', $name->toString());
|
$this->assertSame('foo\bar', $name->toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetFirst() {
|
public function testSetFirst() {
|
||||||
$name = new Name('foo');
|
$name = new Name('foo');
|
||||||
|
|
||||||
$name->setFirst('bar');
|
$name->setFirst('bar');
|
||||||
$this->assertEquals('bar', $name->toString());
|
$this->assertSame('bar', $name->toString());
|
||||||
|
|
||||||
$name->setFirst('A\B');
|
$name->setFirst('A\B');
|
||||||
$this->assertEquals('A\B', $name->toString());
|
$this->assertSame('A\B', $name->toString());
|
||||||
|
|
||||||
$name->setFirst('C');
|
$name->setFirst('C');
|
||||||
$this->assertEquals('C\B', $name->toString());
|
$this->assertSame('C\B', $name->toString());
|
||||||
|
|
||||||
$name->setFirst('D\E');
|
$name->setFirst('D\E');
|
||||||
$this->assertEquals('D\E\B', $name->toString());
|
$this->assertSame('D\E\B', $name->toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetLast() {
|
public function testSetLast() {
|
||||||
$name = new Name('foo');
|
$name = new Name('foo');
|
||||||
|
|
||||||
$name->setLast('bar');
|
$name->setLast('bar');
|
||||||
$this->assertEquals('bar', $name->toString());
|
$this->assertSame('bar', $name->toString());
|
||||||
|
|
||||||
$name->setLast('A\B');
|
$name->setLast('A\B');
|
||||||
$this->assertEquals('A\B', $name->toString());
|
$this->assertSame('A\B', $name->toString());
|
||||||
|
|
||||||
$name->setLast('C');
|
$name->setLast('C');
|
||||||
$this->assertEquals('A\C', $name->toString());
|
$this->assertSame('A\C', $name->toString());
|
||||||
|
|
||||||
$name->setLast('D\E');
|
$name->setLast('D\E');
|
||||||
$this->assertEquals('A\D\E', $name->toString());
|
$this->assertSame('A\D\E', $name->toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAppend() {
|
public function testAppend() {
|
||||||
$name = new Name('foo');
|
$name = new Name('foo');
|
||||||
|
|
||||||
$name->append('bar');
|
$name->append('bar');
|
||||||
$this->assertEquals('foo\bar', $name->toString());
|
$this->assertSame('foo\bar', $name->toString());
|
||||||
|
|
||||||
$name->append('bar\foo');
|
$name->append('bar\foo');
|
||||||
$this->assertEquals('foo\bar\bar\foo', $name->toString());
|
$this->assertSame('foo\bar\bar\foo', $name->toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPrepend() {
|
public function testPrepend() {
|
||||||
$name = new Name('foo');
|
$name = new Name('foo');
|
||||||
|
|
||||||
$name->prepend('bar');
|
$name->prepend('bar');
|
||||||
$this->assertEquals('bar\foo', $name->toString());
|
$this->assertSame('bar\foo', $name->toString());
|
||||||
|
|
||||||
$name->prepend('foo\bar');
|
$name->prepend('foo\bar');
|
||||||
$this->assertEquals('foo\bar\bar\foo', $name->toString());
|
$this->assertSame('foo\bar\bar\foo', $name->toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIs() {
|
public function testIs() {
|
||||||
|
@ -8,7 +8,7 @@ class StringTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @dataProvider provideTestParseEscapeSequences
|
* @dataProvider provideTestParseEscapeSequences
|
||||||
*/
|
*/
|
||||||
public function testParseEscapeSequences($expected, $string, $quote) {
|
public function testParseEscapeSequences($expected, $string, $quote) {
|
||||||
$this->assertEquals(
|
$this->assertSame(
|
||||||
$expected,
|
$expected,
|
||||||
String::parseEscapeSequences($string, $quote)
|
String::parseEscapeSequences($string, $quote)
|
||||||
);
|
);
|
||||||
@ -18,7 +18,7 @@ class StringTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @dataProvider provideTestParse
|
* @dataProvider provideTestParse
|
||||||
*/
|
*/
|
||||||
public function testCreate($expected, $string) {
|
public function testCreate($expected, $string) {
|
||||||
$this->assertEquals(
|
$this->assertSame(
|
||||||
$expected,
|
$expected,
|
||||||
String::parse($string)
|
String::parse($string)
|
||||||
);
|
);
|
||||||
|
@ -37,6 +37,6 @@ class ClassTest extends \PHPUnit_Framework_TestCase
|
|||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($methods, $class->getMethods());
|
$this->assertSame($methods, $class->getMethods());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,13 +25,13 @@ class NodeAbstractTest extends \PHPUnit_Framework_TestCase
|
|||||||
'PhpParser_Node_Dummy'
|
'PhpParser_Node_Dummy'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals('Dummy', $node->getType());
|
$this->assertSame('Dummy', $node->getType());
|
||||||
$this->assertEquals(array('subNode'), $node->getSubNodeNames());
|
$this->assertSame(array('subNode'), $node->getSubNodeNames());
|
||||||
$this->assertEquals(10, $node->getLine());
|
$this->assertSame(10, $node->getLine());
|
||||||
$this->assertEquals('/** doc comment */', $node->getDocComment());
|
$this->assertSame('/** doc comment */', $node->getDocComment()->getText());
|
||||||
$this->assertEquals('value', $node->subNode);
|
$this->assertSame('value', $node->subNode);
|
||||||
$this->assertTrue(isset($node->subNode));
|
$this->assertTrue(isset($node->subNode));
|
||||||
$this->assertEquals($attributes, $node->getAttributes());
|
$this->assertSame($attributes, $node->getAttributes());
|
||||||
|
|
||||||
return $node;
|
return $node;
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ class NodeAbstractTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @depends testConstruct
|
* @depends testConstruct
|
||||||
*/
|
*/
|
||||||
public function testGetDocComment(Node $node) {
|
public function testGetDocComment(Node $node) {
|
||||||
$this->assertEquals('/** doc comment */', $node->getDocComment());
|
$this->assertSame('/** doc comment */', $node->getDocComment()->getText());
|
||||||
array_pop($node->getAttribute('comments')); // remove doc comment
|
array_pop($node->getAttribute('comments')); // remove doc comment
|
||||||
$this->assertNull($node->getDocComment());
|
$this->assertNull($node->getDocComment());
|
||||||
array_pop($node->getAttribute('comments')); // remove comment
|
array_pop($node->getAttribute('comments')); // remove comment
|
||||||
@ -53,16 +53,16 @@ class NodeAbstractTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testChange(Node $node) {
|
public function testChange(Node $node) {
|
||||||
// change of line
|
// change of line
|
||||||
$node->setLine(15);
|
$node->setLine(15);
|
||||||
$this->assertEquals(15, $node->getLine());
|
$this->assertSame(15, $node->getLine());
|
||||||
|
|
||||||
// direct modification
|
// direct modification
|
||||||
$node->subNode = 'newValue';
|
$node->subNode = 'newValue';
|
||||||
$this->assertEquals('newValue', $node->subNode);
|
$this->assertSame('newValue', $node->subNode);
|
||||||
|
|
||||||
// indirect modification
|
// indirect modification
|
||||||
$subNode =& $node->subNode;
|
$subNode =& $node->subNode;
|
||||||
$subNode = 'newNewValue';
|
$subNode = 'newNewValue';
|
||||||
$this->assertEquals('newNewValue', $node->subNode);
|
$this->assertSame('newNewValue', $node->subNode);
|
||||||
|
|
||||||
// removal
|
// removal
|
||||||
unset($node->subNode);
|
unset($node->subNode);
|
||||||
@ -77,18 +77,18 @@ class NodeAbstractTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$node->setAttribute('key', 'value');
|
$node->setAttribute('key', 'value');
|
||||||
$this->assertTrue($node->hasAttribute('key'));
|
$this->assertTrue($node->hasAttribute('key'));
|
||||||
$this->assertEquals('value', $node->getAttribute('key'));
|
$this->assertSame('value', $node->getAttribute('key'));
|
||||||
|
|
||||||
$this->assertFalse($node->hasAttribute('doesNotExist'));
|
$this->assertFalse($node->hasAttribute('doesNotExist'));
|
||||||
$this->assertNull($node->getAttribute('doesNotExist'));
|
$this->assertNull($node->getAttribute('doesNotExist'));
|
||||||
$this->assertEquals('default', $node->getAttribute('doesNotExist', 'default'));
|
$this->assertSame('default', $node->getAttribute('doesNotExist', 'default'));
|
||||||
|
|
||||||
$node->setAttribute('null', null);
|
$node->setAttribute('null', null);
|
||||||
$this->assertTrue($node->hasAttribute('null'));
|
$this->assertTrue($node->hasAttribute('null'));
|
||||||
$this->assertNull($node->getAttribute('null'));
|
$this->assertNull($node->getAttribute('null'));
|
||||||
$this->assertNull($node->getAttribute('null', 'default'));
|
$this->assertNull($node->getAttribute('null', 'default'));
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertSame(
|
||||||
array(
|
array(
|
||||||
'key' => 'value',
|
'key' => 'value',
|
||||||
'null' => null,
|
'null' => null,
|
||||||
|
@ -11,7 +11,7 @@ class NodeDumperTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testDump($node, $dump) {
|
public function testDump($node, $dump) {
|
||||||
$dumper = new NodeDumper;
|
$dumper = new NodeDumper;
|
||||||
|
|
||||||
$this->assertEquals($dump, $dumper->dump($node));
|
$this->assertSame($dump, $dumper->dump($node));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provideTestDump() {
|
public function provideTestDump() {
|
||||||
|
@ -133,7 +133,7 @@ EOC;
|
|||||||
$stmts = $parser->parse($code);
|
$stmts = $parser->parse($code);
|
||||||
$stmts = $traverser->traverse($stmts);
|
$stmts = $traverser->traverse($stmts);
|
||||||
|
|
||||||
$this->assertEquals($expectedCode, $prettyPrinter->prettyPrint($stmts));
|
$this->assertSame($expectedCode, $prettyPrinter->prettyPrint($stmts));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -200,7 +200,7 @@ EOC;
|
|||||||
$stmts = $parser->parse($code);
|
$stmts = $parser->parse($code);
|
||||||
$stmts = $traverser->traverse($stmts);
|
$stmts = $traverser->traverse($stmts);
|
||||||
|
|
||||||
$this->assertEquals($expectedCode, $prettyPrinter->prettyPrint($stmts));
|
$this->assertSame($expectedCode, $prettyPrinter->prettyPrint($stmts));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNoResolveSpecialName() {
|
public function testNoResolveSpecialName() {
|
||||||
@ -234,14 +234,14 @@ EOC;
|
|||||||
|
|
||||||
$stmts = $traverser->traverse($stmts);
|
$stmts = $traverser->traverse($stmts);
|
||||||
|
|
||||||
$this->assertEquals('NS\\A', (string) $stmts[0]->stmts[0]->namespacedName);
|
$this->assertSame('NS\\A', (string) $stmts[0]->stmts[0]->namespacedName);
|
||||||
$this->assertEquals('NS\\B', (string) $stmts[0]->stmts[1]->namespacedName);
|
$this->assertSame('NS\\B', (string) $stmts[0]->stmts[1]->namespacedName);
|
||||||
$this->assertEquals('NS\\C', (string) $stmts[0]->stmts[2]->namespacedName);
|
$this->assertSame('NS\\C', (string) $stmts[0]->stmts[2]->namespacedName);
|
||||||
$this->assertEquals('NS\\D', (string) $stmts[0]->stmts[3]->consts[0]->namespacedName);
|
$this->assertSame('NS\\D', (string) $stmts[0]->stmts[3]->consts[0]->namespacedName);
|
||||||
$this->assertEquals('A', (string) $stmts[1]->stmts[0]->namespacedName);
|
$this->assertSame('A', (string) $stmts[1]->stmts[0]->namespacedName);
|
||||||
$this->assertEquals('B', (string) $stmts[1]->stmts[1]->namespacedName);
|
$this->assertSame('B', (string) $stmts[1]->stmts[1]->namespacedName);
|
||||||
$this->assertEquals('C', (string) $stmts[1]->stmts[2]->namespacedName);
|
$this->assertSame('C', (string) $stmts[1]->stmts[2]->namespacedName);
|
||||||
$this->assertEquals('D', (string) $stmts[1]->stmts[3]->consts[0]->namespacedName);
|
$this->assertSame('D', (string) $stmts[1]->stmts[3]->consts[0]->namespacedName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddTraitNamespacedName() {
|
public function testAddTraitNamespacedName() {
|
||||||
@ -254,8 +254,8 @@ EOC;
|
|||||||
|
|
||||||
$stmts = $traverser->traverse($stmts);
|
$stmts = $traverser->traverse($stmts);
|
||||||
|
|
||||||
$this->assertEquals('NS\\A', (string) $stmts[0]->stmts[0]->namespacedName);
|
$this->assertSame('NS\\A', (string) $stmts[0]->stmts[0]->namespacedName);
|
||||||
$this->assertEquals('A', (string) $stmts[1]->stmts[0]->namespacedName);
|
$this->assertSame('A', (string) $stmts[1]->stmts[0]->namespacedName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -329,7 +329,7 @@ EOC;
|
|||||||
$stmts = $traverser->traverse($stmts);
|
$stmts = $traverser->traverse($stmts);
|
||||||
$stmt = $stmts[0];
|
$stmt = $stmts[0];
|
||||||
|
|
||||||
$this->assertEquals(array('Bar', 'Baz'), $stmt->stmts[1]->expr->class->parts);
|
$this->assertSame(array('Bar', 'Baz'), $stmt->stmts[1]->expr->class->parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSpecialClassNamesAreCaseInsensitive() {
|
public function testSpecialClassNamesAreCaseInsensitive() {
|
||||||
@ -358,8 +358,8 @@ EOC;
|
|||||||
$classStmt = $stmts[0];
|
$classStmt = $stmts[0];
|
||||||
$methodStmt = $classStmt->stmts[0]->stmts[0];
|
$methodStmt = $classStmt->stmts[0]->stmts[0];
|
||||||
|
|
||||||
$this->assertEquals('SELF', (string)$methodStmt->stmts[0]->class);
|
$this->assertSame('SELF', (string)$methodStmt->stmts[0]->class);
|
||||||
$this->assertEquals('PARENT', (string)$methodStmt->stmts[1]->class);
|
$this->assertSame('PARENT', (string)$methodStmt->stmts[1]->class);
|
||||||
$this->assertEquals('STATIC', (string)$methodStmt->stmts[2]->class);
|
$this->assertSame('STATIC', (string)$methodStmt->stmts[2]->class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ class ParserTest extends CodeTestAbstract
|
|||||||
$dumper = new NodeDumper;
|
$dumper = new NodeDumper;
|
||||||
|
|
||||||
$stmts = $parser->parse($code);
|
$stmts = $parser->parse($code);
|
||||||
$this->assertEquals(
|
$this->assertSame(
|
||||||
$this->canonicalize($dump),
|
$this->canonicalize($dump),
|
||||||
$this->canonicalize($dumper->dump($stmts)),
|
$this->canonicalize($dumper->dump($stmts)),
|
||||||
$name
|
$name
|
||||||
@ -36,7 +36,7 @@ class ParserTest extends CodeTestAbstract
|
|||||||
|
|
||||||
$this->fail(sprintf('"%s": Expected Error', $name));
|
$this->fail(sprintf('"%s": Expected Error', $name));
|
||||||
} catch (Error $e) {
|
} catch (Error $e) {
|
||||||
$this->assertEquals($msg, $e->getMessage(), $name);
|
$this->assertSame($msg, $e->getMessage(), $name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ class PrettyPrinterTest extends CodeTestAbstract
|
|||||||
$prettyPrinter = new PrettyPrinter\Standard;
|
$prettyPrinter = new PrettyPrinter\Standard;
|
||||||
|
|
||||||
$stmts = $parser->parse($code);
|
$stmts = $parser->parse($code);
|
||||||
$this->assertEquals(
|
$this->assertSame(
|
||||||
$this->canonicalize($dump),
|
$this->canonicalize($dump),
|
||||||
$this->canonicalize($prettyPrinter->$method($stmts)),
|
$this->canonicalize($prettyPrinter->$method($stmts)),
|
||||||
$name
|
$name
|
||||||
|
Loading…
Reference in New Issue
Block a user