From 264cd8ee11bbf3a956fa9c6d63272a4e2a243330 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sun, 19 Oct 2014 17:21:13 +0200 Subject: [PATCH] #615 - Refactoring test case to remove duplication --- .../Tests/ORM/Query/SqlWalkerTest.php | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php b/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php index 1ea0808b1..263cffc56 100644 --- a/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php @@ -14,15 +14,25 @@ use Doctrine\ORM\Query\ParserResult; */ class SqlWalkerTest extends OrmTestCase { + /** + * @var SqlWalker + */ + private $sqlWalker; + + /** + * {@inheritDoc} + */ + protected function setUp() + { + $this->sqlWalker = new SqlWalker(new Query($this->_getTestEntityManager()), new ParserResult(), array()); + } + /** * @dataProvider getColumnNamesAndSqlAliases */ public function testGetSQLTableAlias($tableName, $expectedAlias) { - $query = new Query($this->_getTestEntityManager()); - $sqlWalker = new SqlWalker($query, new ParserResult(), array()); - - $this->assertSame($expectedAlias, $sqlWalker->getSQLTableAlias($tableName)); + $this->assertSame($expectedAlias, $this->sqlWalker->getSQLTableAlias($tableName)); } /** @@ -30,10 +40,10 @@ class SqlWalkerTest extends OrmTestCase */ public function testGetSQLTableAliasIsSameForMultipleCalls($tableName) { - $query = new Query($this->_getTestEntityManager()); - $sqlWalker = new SqlWalker($query, new ParserResult(), array()); - - $this->assertSame($sqlWalker->getSQLTableAlias($tableName), $sqlWalker->getSQLTableAlias($tableName)); + $this->assertSame( + $this->sqlWalker->getSQLTableAlias($tableName), + $this->sqlWalker->getSQLTableAlias($tableName) + ); } /**