@@ -17,49 +17,49 @@ discard block |
||
17 | 17 | final class GH7262Test extends \Doctrine\Tests\OrmFunctionalTestCase |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * Setup test case with custom quote strategy. |
|
22 | - */ |
|
23 | - public function setUp() |
|
24 | - { |
|
20 | + /** |
|
21 | + * Setup test case with custom quote strategy. |
|
22 | + */ |
|
23 | + public function setUp() |
|
24 | + { |
|
25 | 25 | parent::setUp(); |
26 | 26 | |
27 | 27 | $this->_em |
28 | - ->getConfiguration() |
|
29 | - ->setQuoteStrategy(new QuoteStrategyMock()); |
|
28 | + ->getConfiguration() |
|
29 | + ->setQuoteStrategy(new QuoteStrategyMock()); |
|
30 | 30 | |
31 | 31 | try { |
32 | - $this->_schemaTool->createSchema( |
|
32 | + $this->_schemaTool->createSchema( |
|
33 | 33 | [ |
34 | - $this->_em->getClassMetadata(SimpleEntity::class), |
|
34 | + $this->_em->getClassMetadata(SimpleEntity::class), |
|
35 | 35 | ] |
36 | - ); |
|
36 | + ); |
|
37 | 37 | } catch (\Exception $e) { |
38 | 38 | } |
39 | 39 | |
40 | 40 | PersistentObject::setObjectManager($this->_em); |
41 | - } |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Tests that the custom quote strategy is set. |
|
45 | - */ |
|
46 | - public function testQuoteStrategyIsSet() |
|
47 | - { |
|
43 | + /** |
|
44 | + * Tests that the custom quote strategy is set. |
|
45 | + */ |
|
46 | + public function testQuoteStrategyIsSet() |
|
47 | + { |
|
48 | 48 | $this->assertEquals( |
49 | - QuoteStrategyMock::class, |
|
50 | - get_class($this->_em->getConfiguration()->getQuoteStrategy()), |
|
51 | - 'Quote strategy of type ' . QuoteStrategyMock::class . ' is required.' |
|
49 | + QuoteStrategyMock::class, |
|
50 | + get_class($this->_em->getConfiguration()->getQuoteStrategy()), |
|
51 | + 'Quote strategy of type ' . QuoteStrategyMock::class . ' is required.' |
|
52 | 52 | ); |
53 | - } |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Tests finding persisted entities while quote strategy is enabled. |
|
57 | - * |
|
58 | - * @throws \Doctrine\ORM\ORMException |
|
59 | - * @throws \Doctrine\ORM\OptimisticLockException |
|
60 | - */ |
|
61 | - public function testFindPersistedEntitiesWithActiveQuoteStrategy() |
|
62 | - { |
|
55 | + /** |
|
56 | + * Tests finding persisted entities while quote strategy is enabled. |
|
57 | + * |
|
58 | + * @throws \Doctrine\ORM\ORMException |
|
59 | + * @throws \Doctrine\ORM\OptimisticLockException |
|
60 | + */ |
|
61 | + public function testFindPersistedEntitiesWithActiveQuoteStrategy() |
|
62 | + { |
|
63 | 63 | $entity = new SimpleEntity(); |
64 | 64 | |
65 | 65 | $this->_em->persist($entity); |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | $this->assertNotEmpty($entity->id, 'Primary key after persisting an entity expected.'); |
69 | 69 | |
70 | 70 | $entities = $this->_em->getRepository(SimpleEntity::class) |
71 | - ->findAll(); |
|
71 | + ->findAll(); |
|
72 | 72 | |
73 | 73 | $this->assertNotEmpty($entities, 'One persisted entity expected.'); |
74 | - } |
|
74 | + } |
|
75 | 75 | |
76 | 76 | } |
77 | 77 | \ No newline at end of file |
@@ -19,56 +19,56 @@ |
||
19 | 19 | final class QuoteStrategyMock extends AnsiQuoteStrategy |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * {@inheritdoc} |
|
24 | - */ |
|
25 | - public function getTableName(ClassMetadata $class, AbstractPlatform $platform) |
|
26 | - { |
|
22 | + /** |
|
23 | + * {@inheritdoc} |
|
24 | + */ |
|
25 | + public function getTableName(ClassMetadata $class, AbstractPlatform $platform) |
|
26 | + { |
|
27 | 27 | return $this->quote(parent::getTableName($class, $platform), $platform); |
28 | - } |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * {@inheritdoc} |
|
32 | - */ |
|
33 | - public function getColumnName($fieldName, ClassMetadata $class, AbstractPlatform $platform) |
|
34 | - { |
|
30 | + /** |
|
31 | + * {@inheritdoc} |
|
32 | + */ |
|
33 | + public function getColumnName($fieldName, ClassMetadata $class, AbstractPlatform $platform) |
|
34 | + { |
|
35 | 35 | return $this->quote(parent::getColumnName($fieldName, $class, $platform), $platform); |
36 | - } |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * {@inheritdoc} |
|
40 | - */ |
|
41 | - public function getColumnAlias($columnName, $counter, AbstractPlatform $platform, ClassMetadata $class = NULL) |
|
42 | - { |
|
38 | + /** |
|
39 | + * {@inheritdoc} |
|
40 | + */ |
|
41 | + public function getColumnAlias($columnName, $counter, AbstractPlatform $platform, ClassMetadata $class = NULL) |
|
42 | + { |
|
43 | 43 | return $this->quote($columnName, $platform); |
44 | - } |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Quotes a string depending on the current platform. |
|
48 | - * |
|
49 | - * @param string $string |
|
50 | - * The string to quote. |
|
51 | - * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
|
52 | - * The current platform. |
|
53 | - * |
|
54 | - * @return string |
|
55 | - * The quoted string if the platform could be detected. |
|
56 | - */ |
|
57 | - private function quote(string $string, AbstractPlatform $platform) |
|
58 | - { |
|
46 | + /** |
|
47 | + * Quotes a string depending on the current platform. |
|
48 | + * |
|
49 | + * @param string $string |
|
50 | + * The string to quote. |
|
51 | + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
|
52 | + * The current platform. |
|
53 | + * |
|
54 | + * @return string |
|
55 | + * The quoted string if the platform could be detected. |
|
56 | + */ |
|
57 | + private function quote(string $string, AbstractPlatform $platform) |
|
58 | + { |
|
59 | 59 | |
60 | 60 | switch ($platform->getName()) { |
61 | - case 'sqlite': |
|
61 | + case 'sqlite': |
|
62 | 62 | case 'mysql': |
63 | 63 | return "`{$string}`"; |
64 | - case 'pgsql': |
|
64 | + case 'pgsql': |
|
65 | 65 | return "'{$string}'"; |
66 | - case 'mssql': |
|
66 | + case 'mssql': |
|
67 | 67 | return "[{$string}]"; |
68 | 68 | } |
69 | 69 | |
70 | 70 | return $string; |
71 | - } |
|
71 | + } |
|
72 | 72 | |
73 | 73 | |
74 | 74 | } |
75 | 75 | \ No newline at end of file |
@@ -117,12 +117,12 @@ |
||
117 | 117 | |
118 | 118 | // Generate quoted column alias or column name for column info hydrating. |
119 | 119 | if (preg_match(',(.+)_(\d+)$,', $column, $matches)) { |
120 | - $column = $this->_em->getConfiguration() |
|
120 | + $column = $this->_em->getConfiguration() |
|
121 | 121 | ->getQuoteStrategy() |
122 | 122 | ->getColumnAlias($matches[1], $matches[2], $this->_platform, $this->getClassMetadata($entityName)); |
123 | 123 | } |
124 | 124 | else { |
125 | - $column = $this->_em->getConfiguration() |
|
125 | + $column = $this->_em->getConfiguration() |
|
126 | 126 | ->getQuoteStrategy() |
127 | 127 | ->getColumnName($column, $this->getClassMetadata($entityName), $this->_platform); |
128 | 128 | } |