Skip to content

Commit 0fa5a0a

Browse files
author
Yevhen Miroshnychenko
committed
MAGETWO-92986: Write Logs for Failed Process of Generating Factories in Extensions
1 parent b5f28ad commit 0fa5a0a

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

dev/tests/integration/testsuite/Magento/Framework/Code/GeneratorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ public function testGeneratorClassWithErrorSaveClassFile()
196196
{
197197
$exceptionMessageRegExp = '/Error: an object of a generated class may be a dependency for another object, '
198198
. 'but this dependency has not been defined or set correctly in the signature of the related construct '
199-
. 'method\.\nDue to the current error, executing the CLI commands `bin\/magento setup:di:compile` '
200-
. 'or `bin\/magento deploy:mode:set production` does not create the required generated classes\.\nMagento '
201-
. 'cannot write a class file to the "generated" directory that is read\-only\. Before using the read-only '
202-
. 'file system, the classes to be generated must be created beforehand in the "generated" directory\.\n'
199+
. 'method\. Due to the current error, executing the CLI commands `bin\/magento setup:di:compile` '
200+
. 'or `bin\/magento deploy:mode:set production` does not create the required generated classes\. Magento '
201+
. 'cannot write a class file to the "generated" directory that is read-only\. Before using the read-only '
202+
. 'file system, the classes to be generated must be created beforehand in the "generated" directory\. '
203203
. 'For details, see the "File systems access permissions" topic at http:\/\/devdocs\.magento\.com\.\n'
204204
. 'The specified ".*" file couldn\'t be written. in \[.*\]/';
205205

lib/internal/Magento/Framework/Code/Generator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function generateClass($className)
113113
$this->tryToLoadSourceClass($className, $generator);
114114
if (!($file = $generator->generate())) {
115115
/** @var $logger LoggerInterface */
116-
$logger = $this->objectManager->get(LoggerInterface::class);
116+
$logger = $this->getObjectManager()->get(LoggerInterface::class);
117117
$errors = $generator->getErrors();
118118
$message = implode(PHP_EOL, $errors) . ' in [' . $className . ']';
119119
$logger->critical($message);

lib/internal/Magento/Framework/Code/Generator/EntityAbstract.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ public function generate()
109109
}
110110
} catch (FileSystemException $e) {
111111
$message = 'Error: an object of a generated class may be a dependency for another object, but this '
112-
. 'dependency has not been defined or set correctly in the signature of the related construct method.'
112+
. 'dependency has not been defined or set correctly in the signature of the related construct method. '
113113
. 'Due to the current error, executing the CLI commands `bin/magento setup:di:compile` or `bin/magento '
114-
. 'deploy:mode:set production` does not create the required generated classes.'
114+
. 'deploy:mode:set production` does not create the required generated classes. '
115115
. 'Magento cannot write a class file to the "generated" directory that is read-only. Before using the '
116-
. 'read-only file system, the classes to be generated must be created beforehand in the "generated" directory.'
116+
. 'read-only file system, the classes to be generated must be created beforehand in the "generated" directory. '
117117
. 'For details, see the "File systems access permissions" topic at http://devdocs.magento.com.';
118118
$this->_addError($message);
119119
$this->_addError($e->getMessage());

lib/internal/Magento/Framework/Code/Test/Unit/Generator/EntityAbstractTest.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,16 @@ public function testGenerate(
215215
/**
216216
* @inheritdoc
217217
*/
218-
public function testGenerateFailure() {
219-
220-
$infoMessage = <<<'EOT'
221-
Error: an object of a generated class may be a dependency for another object, but this dependency has not been defined or set correctly in the signature of the related construct method.
222-
Due to the current error, executing the CLI commands `bin/magento setup:di:compile` or `bin/magento deploy:mode:set production` does not create the required generated classes.
223-
Magento cannot write a class file to the "generated" directory that is read-only. Before using the read-only file system, the classes to be generated must be created beforehand in the "generated" directory.
224-
For details, see the "File systems access permissions" topic at http://devdocs.magento.com.
225-
EOT;
218+
public function testGenerateFailure()
219+
{
220+
$infoMessage = 'Error: an object of a generated class may be a dependency for another object, but this '
221+
. 'dependency has not been defined or set correctly in the signature of the related construct method. '
222+
. 'Due to the current error, executing the CLI commands `bin/magento setup:di:compile` or `bin/magento '
223+
. 'deploy:mode:set production` does not create the required generated classes. '
224+
. 'Magento cannot write a class file to the "generated" directory that is read-only. Before using the '
225+
. 'read-only file system, the classes to be generated must be created beforehand in the "generated" directory. '
226+
. 'For details, see the "File systems access permissions" topic at http://devdocs.magento.com.';
227+
226228
$exceptionMessage = 'Some description';
227229

228230
$abstractGetters = ['_getClassProperties', '_getClassMethods'];
@@ -254,6 +256,7 @@ public function testGenerateFailure() {
254256
$this->assertFalse($result);
255257
$this->assertEquals([$infoMessage, $exceptionMessage], $this->_model->getErrors());
256258
}
259+
257260
/**
258261
* Prepares mocks for validation verification
259262
*

0 commit comments

Comments
 (0)