Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace and path inconsistencies with Yii2 Testing documentation #155

Open
vercotux opened this issue Nov 9, 2017 · 5 comments
Open
Assignees
Labels
status:ready for adoption Feel free to implement this issue. type:docs Documentation

Comments

@vercotux
Copy link

vercotux commented Nov 9, 2017

This is not a question. It is an issue pointing out the inconsistencies between this project, the yii2 testing documentation and other yii2 components, which have resulted in costing developers dozens of workhours trying to figure out.

In the Yii2 Testing Documentation the namespace for codeception unit tests is shown as:
namespace app\tests\unit\models;

Meanwhile in yii2-app-basic (which also uses codeception) the namespace for codeception unit tests is: namespace tests\models;.

Which convention are we supposed to follow? Why are they different?

The whole thing becomes even more confusing when you try to figure out fixtures.
According to Yii2 Testing Documentation, test fixtures are supposed to be located under the following namespace:
app\tests\fixtures

But then the same documentation says:

By default fixtures will be searched under tests\unit\fixtures namespace

This seems to match the default path for fixtures generated by yii2-faker which is
@tests/unit/fixtures/data

However, the Yii2 Testing Documentation then gives an example of the data path as:

// fixture data located in tests/_data/user.php
'dataFile' => codecept_data_dir() . 'user.php'

Why? That is not where yii2-faker puts the generated data by default and the documentation does not explain why it is different.

Could we please do something about it? IMO the template apps and other related components should accurately reflect what is described in the documentation, not implement it in their own unique way.

@samdark samdark added the type:docs Documentation label Nov 9, 2017
@samdark samdark added this to the 2.0.14 milestone Nov 9, 2017
@samdark samdark self-assigned this Nov 9, 2017
@samdark samdark added the status:ready for adoption Feel free to implement this issue. label Feb 17, 2018
@samdark samdark modified the milestones: 2.0.14, 2.0.15 Feb 17, 2018
@ricpelo
Copy link
Contributor

ricpelo commented Feb 24, 2018

Seems to be related to yiisoft/yii2-faker#31.

@ricpelo
Copy link
Contributor

ricpelo commented Feb 24, 2018

Aside from that, why fixtures should be inside the unit directory? Are fixtures related only to unit testing, and not to functional or acceptance testing?

@ricpelo
Copy link
Contributor

ricpelo commented Feb 25, 2018

I've split this issue into tree different ones with their corresponding PR's:

Issue PR
#170 #171
yiisoft/yii2#15769 yiisoft/yii2#15770
yiisoft/yii2-faker#33 yiisoft/yii2-faker#34

@ricpelo
Copy link
Contributor

ricpelo commented Feb 25, 2018

These changes, in addition to providing necessary consistency, brings compatibility with extensions like ElisDN/yii2-gii-fixture-generator:

public $fixtureNs = 'tests\fixtures';
public $dataPath = '@tests/fixtures/data';

See:
https://github.com/ElisDN/yii2-gii-fixture-generator/blob/648782b60d346a17baa273a32e9a424717b6f0c9/src/Generator.php#L20-L22

@samdark samdark modified the milestones: 2.0.16, 2.0.17 Jan 27, 2019
@samdark samdark removed this from the 2.0.17 milestone Mar 22, 2019
@mtangoo
Copy link

mtangoo commented Nov 1, 2019

Bumped the same confusion. tests\* is not working . Am going to change everything to app\tests*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready for adoption Feel free to implement this issue. type:docs Documentation
Projects
None yet
Development

No branches or pull requests

4 participants