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

Tests for Cli/Console #13719

Merged
merged 14 commits into from Jan 10, 2019

Conversation

Projects
3 participants
@npfedwards
Copy link
Contributor

npfedwards commented Dec 28, 2018

Hello!

  • Type: code quality
  • Link to issue: #13654

In raising this pull request, I confirm the following (please check boxes):

  • I have read and understood the Contributing Guidelines?
  • I have checked that another pull request for this purpose does not exist.
  • I wrote some tests for this PR.

Small description of change:
Added new tests for the missing ones for Cli/Console (learned a lot on the way). This includes a minor fix where console->handle() wasn't letting the dispatcher know which module it had used so the test was failing and a readme tweak.

A few caveats

  • Should the line HandleCest.php:151 be required to make it work? $console->dispatcher->setNamespaceName("Phalcon\\Test\\Modules\\Backend\\Tasks"); seems odd behaviour to me.
  • I didn't know what the convention was with docblocks and authors (I haven't read enough of the code), so I added my name below Phalcon Team so you know who to blame, I can change that if that is wrong.
  • I don't know how code coverage is tested/where the results are so I didn't check that I've tested everything.

Thanks

npfedwards added some commits Dec 18, 2018

Merge branch '4.0.x' of https://github.com/phalcon/cphalcon into phal…
…con-4.0.x

# Conflicts:
#	tests/cli/Cli/Console/ConstructCest.php
#	tests/cli/Cli/Console/GetDefaultModuleCest.php
#	tests/cli/Cli/Console/GetEventsManagerCest.php
#	tests/cli/Cli/Console/GetModuleCest.php
#	tests/cli/Cli/Console/GetModulesCest.php
#	tests/cli/Cli/Console/GetSetDefaultModuleCest.php
#	tests/cli/Cli/Console/HandleCest.php
#	tests/cli/Cli/Console/RegisterModulesCest.php
#	tests/cli/Cli/Console/SetArgumentCest.php
#	tests/cli/Cli/Console/SetEventsManagerCest.php
#	tests/cli/Cli/Console/UnderscoreGetCest.php
@npfedwards

This comment has been minimized.

Copy link
Contributor

npfedwards commented Dec 28, 2018

I'll look into why these tests are failing, seems to be unrelated to the changes I made, but I may be wrong.

@ruudboon

This comment has been minimized.

Copy link
Contributor

ruudboon commented Dec 29, 2018

@npfedwards I see some styling errors in the test. Did you try running phpcs on the changed files?And on error fix them with phpcbf

@npfedwards

This comment has been minimized.

Copy link
Contributor

npfedwards commented Dec 29, 2018

@ruudboon I spotted them and I've fixed them just not done that in the right branch yet. Given PhpStorm is set up to use spaces I'm so confused why I have tabs everywhere! I've set up phpcs as an inspection on it now.

Merge branch '4.0.x_cli_console_tests' into phalcon-4.0.x
# Conflicts:
#	tests/cli/Cli/Console/RegisterModulesCest.php
@niden

This comment has been minimized.

Copy link
Member

niden commented Dec 30, 2018

@npfedwards Add the editorconfig plugin for storm and you will have no problems after that. It will detect tabs for zep files and spaces for php :)

@niden niden added the Testing label Dec 30, 2018

@niden niden added this to In progress in 4.0 Release via automation Dec 30, 2018

@npfedwards

This comment has been minimized.

Copy link
Contributor

npfedwards commented Dec 31, 2018

Thanks @niden. I'm on holiday for the next few days but will be working out why my tests had weird side effects after that.

@niden

This comment has been minimized.

Copy link
Member

niden commented Jan 3, 2019

@npfedwards I hope you had a nice break :)

From what I see in the log all you will have to do is to run phpcbf in your nanobox environment and that should fix the issue that makes the build fail

@npfedwards

This comment has been minimized.

Copy link
Contributor

npfedwards commented Jan 4, 2019

@niden I actually have some failing tests (nothing to do with the ones I've written). For example the session tests all seem to fail now. I might have an idea that some output isn't caught by the output buffer - hence session can't start.

npfedwards added some commits Jan 4, 2019

@codecov

This comment has been minimized.

Copy link

codecov bot commented Jan 6, 2019

Codecov Report

Merging #13719 into 4.0.x will increase coverage by 0.41%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##            4.0.x   #13719      +/-   ##
==========================================
+ Coverage   65.66%   66.08%   +0.41%     
==========================================
  Files         396      396              
  Lines       88244    88253       +9     
==========================================
+ Hits        57947    58321     +374     
+ Misses      30297    29932     -365
Impacted Files Coverage Δ
ext/phalcon/translate/adapter/nativearray.zep.c 85.98% <0%> (-0.16%) ⬇️
ext/phalcon/cache/backend/redis.zep.c 58.34% <0%> (-0.08%) ⬇️
ext/phalcon/dispatcher.zep.c 80.62% <0%> (+0.85%) ⬆️
ext/phalcon/di.zep.c 73.82% <0%> (+3.79%) ⬆️
ext/phalcon/cli/console.zep.c 92.17% <0%> (+11.99%) ⬆️
ext/phalcon/application.zep.c 92.03% <0%> (+23.89%) ⬆️
ext/phalcon/config/adapter/yaml.zep.c 69.35% <0%> (+64.51%) ⬆️
ext/phalcon/cache/backend/apcu.zep.c 76.66% <0%> (+75.67%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update db0ed22...11bb9d0. Read the comment docs.

npfedwards added some commits Jan 6, 2019

@npfedwards

This comment has been minimized.

Copy link
Contributor

npfedwards commented Jan 6, 2019

Just added a fix and test for #13724 because I needed some of the fixtures I'd written in this PR to test it.

@niden
Copy link
Member

niden left a comment

This looks great!! Thank you so much.

A couple of comments. Also please add an entry to the CHANGELOG for the change in console.zep

[
"frontend" => [
"className" => "Phalcon\\Test\\Modules\\Frontend\\Module",
"path" => __DIR__ . "/../../../_data/fixtures/modules/frontend/Module.php",

This comment has been minimized.

@niden

niden Jan 10, 2019

Member

Can we use dataFolder() here instead of the __DIR__ etc.?

],
"backend" => [
"className" => "Phalcon\\Test\\Modules\\Backend\\Module",
"path" => __DIR__ . "/../../../_data/fixtures/modules/backend/Module.php",

This comment has been minimized.

@niden

niden Jan 10, 2019

Member

Same

[
"frontend" => [
"className" => "Phalcon\\Test\\Modules\\Frontend\\Module",
"path" => __DIR__ . "/../../../_data/fixtures/modules/frontend/Module.php",

This comment has been minimized.

@niden

niden Jan 10, 2019

Member

Same

* @author Nathan Edwards <https://github.com/npfedwards>
* @since 2018-12-26
*/
public function cliConsoleHandleEvents(CliTester $I)

This comment has been minimized.

@niden

niden Jan 10, 2019

Member

I would like to split this test into smaller ones if possible. It makes it easier to figure out what is tested and where.

Perhaps create something in the lines of

cliConsoleHandleEventBoot
cliConsoleHandleEventBeforeStartModule
etc.

[
"backend" => [
"className" => "Phalcon\\Test\\Modules\\Backend\\Module",
"path" => __DIR__ . "/../../../_data/fixtures/modules/backend/Module.php",

This comment has been minimized.

@niden

niden Jan 10, 2019

Member

Same here for dataFolder()

@npfedwards

This comment has been minimized.

Copy link
Contributor

npfedwards commented Jan 10, 2019

@niden Et voila

@niden niden merged commit 11bb9d0 into phalcon:4.0.x Jan 10, 2019

4 checks passed

codecov/patch Coverage not affected when comparing db0ed22...11bb9d0
Details
codecov/project 66.08% (+0.41%) compared to db0ed22
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

4.0 Release automation moved this from In progress to Done Jan 10, 2019

@niden

This comment has been minimized.

Copy link
Member

niden commented Jan 10, 2019

@npfedwards Thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment