Skip to content

Failed Test due to Class not following the naming convention  #925

@amacgregor

Description

@amacgregor

The class naming convention seems to be inconsistent and causing some problems for example I run into the following issue while running the unit tests for the Magento catalog Models

~/Projects/Github/magento2 on ⭠ develop! ⌚ 11:27:10
$ vendor/bin/phpunit  --configuration /home/amacgregor/Projects/Github/magento2/dev/tests/unit/phpunit.xml.dist /home/amacgregor/Projects/Github/magento2/dev/tests/unit/testsuite/Magento/Catalog/            
PHPUnit 4.1.0 by Sebastian Bergmann.

Configuration read from /media/projects/Github/magento2/dev/tests/unit/phpunit.xml.dist

...............................................................  63 / 912 (  6%)
............................................................... 126 / 912 ( 13%)
............................................................... 189 / 912 ( 20%)
........................................I.I.................... 252 / 912 ( 27%)
............................................................... 315 / 912 ( 34%)
............................................................... 378 / 912 ( 41%)
............................................................... 441 / 912 ( 48%)
.............................E................................. 504 / 912 ( 55%)
............................................................... 567 / 912 ( 62%)
............................................................... 630 / 912 ( 69%)
............................................................... 693 / 912 ( 75%)
............................................................... 756 / 912 ( 82%)
............................................................... 819 / 912 ( 89%)
............................................................... 882 / 912 ( 96%)
..............................

Time: 18.35 seconds, Memory: 235.25Mb

There was 1 error:

1) Magento\Catalog\Model\Product\Attribute\Backend\GroupPriceTest::testIsScaler
ReflectionException: Class Magento\Catalog\Model\Product\Attribute\Backend\GroupPrice does not exist

/media/projects/Github/magento2/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php:160
/media/projects/Github/magento2/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/GroupPriceTest.php:23

FAILURES!                                              
Tests: 912, Assertions: 2703, Errors: 1, Incomplete: 2.

Looking at the test class in more detail, we can see that is trying to create an instance of the following class

$this->model = $this->objectHelper->getObject('Magento\Catalog\Model\Product\Attribute\Backend\GroupPrice');

Unfortunately, the actual class is called:

class Groupprice extends \Magento\Catalog\Model\Product\Attribute\Backend\Groupprice\AbstractGroupprice

Now the naming seems to be sort of inconsistent because the same module has classes using camel casing and only the first later capitalized.

What should be the correct naming convention? the fix for this issue depends on whether the naming is correct or not.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions