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

Application config as array (Yii1 Module) #267

Merged
merged 2 commits into from Apr 15, 2013

Conversation

schmunk42
Copy link
Contributor

Like in CWebApplication in Yii, this patch allows you to also pass a configuration array to initialize the app and run the tests.

@Ragazzo
Copy link
Contributor

Ragazzo commented Apr 14, 2013

Hm, dont know if it really needed, can u paste maybe some code of your suite .yml file? Or i think that if it really needed than it must be an array_merger()(or CMap) so in this way config from .yml file will override some other settings in default config.
btw. did u checked out new cests ? you can use them for acceptance/functional tests with some fixtures improvements by _before/_after/_failed method.

@schmunk42
Copy link
Contributor Author

About the Cests, I am using the latest stable via composer, Codeception 1.0.6.3.
I also ran the build command and have these function. Do I have to do anything else?

Regarding the config parameter from the Yii docs:

application configuration. If a string, it is treated as the path of the file that contains the configuration; If an array, it is the actual configuration information.

http://www.yiiframework.com/doc/api/1.1/CApplication#__construct-detail
http://www.yiiframework.com/doc/api/1.1/CWebApplication

My use case is the following: I'd like to setup a complete test suite with acceptance, functional and unit tests.

As far as I understood from the manual and source-code, the convention of the Yii1 Codeception module is to return an array with two elements, app class and config, instead of creating a web app, like in the default Yii index-test.php

Also, in my index-test.php file, I create a web application for acceptance tests. But this leads to conflicts when trying to use the same index-test.php for both suites.

So for now I use a index-test-functional.php and index-test.php for my tests. You can find my tests and index.php(s) on github. Any advice on this?

But nonetheless I'd support the changes in the pull request, because Yii works that way and you may change config values, if needed, eg. plug in the CodeceptionHttpRequest class.

@DavertMik
Copy link
Member

@Ragazzo i'm leaving decision to merge this or not to you. Ok?

Personally I'd like to see in commit documentation for module updated to reflect this change.
Documentation is written in the same file as module. Before the class declaration.

@Ragazzo
Copy link
Contributor

Ragazzo commented Apr 14, 2013

Hm, right, i also was thinking about this when creating a Yii1 module, but i was trying to make it easy-install, so thats why i chose the way to pass confgi path as a ['config'] param, well i think it can be merged, but can you before change PR according Yii repo style-guide (i will mark what must be changed) and add docs in the module info in module class file?

P.S. as for me i do use codeception in some another way i guess:
I have 2 configs for it: protected/config/codecept/acceptance.php, /protected/config/codecept/functional.php they made with main.php merging through CMap with some additions. I also prefer to use PhpBrowser for functional tests, so i have some helper called Yii1Basic to support basic integration (simply create app), and i use new cest-class formats, so some CRUD operations can be divided in separated protected methods but can be called in right order in one method like (check_basic_crud_in_users_module(\TestGuy $I)), so cest-classes i also prefer for page-object pattern, so i almost do not use plain-files, but they are really simple)) And i also have 2 additional entry points: index-accep.php and index-func.php.

@schmunk42
Copy link
Contributor Author

Yes, let me know what should be changed.
Are your tests available online?

@Ragazzo
Copy link
Contributor

Ragazzo commented Apr 14, 2013

You can also see here simple new cest-format use-case for tests:
#217 (comment)
Sorry, no, not available, i hope i will write maybe some article on yii wiki if i have more time)

@Ragazzo
Copy link
Contributor

Ragazzo commented Apr 14, 2013

Reformat: just delete { in if-else condition, and i am for merging this PR)

@schmunk42
Copy link
Contributor Author

Just to make sure, like this:

if (is_array($this->appSettings['config']))
  $this->_appConfig = $this->appSettings['config'];
else
  $this->_appConfig = require_once($this->appSettings['config']);

Where can I find the coding standard? I already wondered about the tabs ;)

@Ragazzo
Copy link
Contributor

Ragazzo commented Apr 15, 2013

Yes, like that. Unfortunately there is no coding standard in codeception(( so i prefer to use some standard that already was used in the file, so as for Yii1 when it was developing standard from https://github.com/Ragazzo/yii/wiki/Core-framework-code-style was taken, so this is how it all goes)
P.S. i see u are from Stuttgart, so congrats with the victory against Gladbach in 29 tour :D of course if you watch Bundesliga))

@Ragazzo
Copy link
Contributor

Ragazzo commented Apr 15, 2013

will merge it, some code-style refactoring can be done later)

Ragazzo pushed a commit that referenced this pull request Apr 15, 2013
Application config as array (Yii1 Module)
@Ragazzo Ragazzo merged commit f9ec712 into Codeception:master Apr 15, 2013
@Ragazzo
Copy link
Contributor

Ragazzo commented Apr 15, 2013

It is also will be good to hear your opinion/thoughts on idea of tags in codeception, you can see this issue and leave there some suggestions maybe, if u will have time) #262

@schmunk42
Copy link
Contributor Author

Hey, thanks. To be honest I've never noticed, that Yii uses tabs ;)
And sure I watch Bundesliga, I am also a fan of VfB Stuttgart, but they're so lousy this season :(

btw: I'd like to ask some more questions over here: http://www.yiiframework.com/forum/index.php/topic/39379-yii-codeception-module/ I hope you'll have a look.

@schmunk42 schmunk42 deleted the patch-yii-config-array branch April 15, 2013 13:24
@Ragazzo
Copy link
Contributor

Ragazzo commented Apr 15, 2013

yes, you can ask questions there, i also check 1-2 times in day yii-en topic there)) but for now as i can see last message is mine there)

@schmunk42
Copy link
Contributor Author

About tags: Sorry, I am not very experienced with testing - I've no clue atm what you're trying to do?!

But could you add (or point me to) a section where Cest and Cept are explained in detail, like what's the difference between them and Unit test - I found just one paragraph in the docs.

@Ragazzo
Copy link
Contributor

Ragazzo commented Apr 15, 2013

Ok, so cests was refactored and old version of them was dropped, so i think article is really needed, ok i will try to get some more free time for this. As for unit-tests as i said before i use classic phpunit unit-tests so i think that it is more question for the @DavertMik to write more guides about unit-testing in codeception, so some more things that i can say here is that you may already noticed yii plugin directory(plugins/frameworks/yii/), so CDbTestCase and CTestCase are also supported out of the box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants