Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

Write tests #58

Merged
merged 22 commits into from
Nov 10, 2015
Merged

Write tests #58

merged 22 commits into from
Nov 10, 2015

Conversation

Hywan
Copy link
Member

@Hywan Hywan commented Oct 15, 2015

Now we have an Output interface, this is much easier to test the Hoa\Console library. So here we go. I am writing tests :-].

Steps

  • Console,
  • Cursor,
  • GetOption,
  • Input,
  • Mouse,
  • Output,
  • Parser,
  • Processus,
  • Readline:
    • Readline,
    • Password,
    • Autocompleter:
      • Path,
      • Word,
      • Aggregator,
  • Tput,
  • Window.

@Hywan
Copy link
Member Author

Hywan commented Oct 27, 2015

Success (6 tests, 177/177 methods, 0 void method, 0 skipped method, 325 assertions)!

\o/

@Hywan
Copy link
Member Author

Hywan commented Oct 27, 2015

Success (7 tests, 199/199 methods, 0 void method, 0 skipped method, 356 assertions)!

\o/

@Hywan
Copy link
Member Author

Hywan commented Oct 28, 2015

Success (8 tests, 207/207 methods, 0 void method, 0 skipped method, 378 assertions)!

\o/

*/
class Cursor extends Test\Unit\Suite
{
public function setUp()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is probably not what you want here: to execute an initialization before each test method (in the method sub-process) you should override beforeTestMethod

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, it also works, but this is part of the setup too, no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hywan the setUp is executed in the main process while beforeTestMethod is in the child process. Your initialization might not be applied when running test methods.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok, correct!

Sometimes, `STDIN` is not defined when trying to start advanced
interactions. So we must ensure that `STDIN` is correctly set.
Now we are able to set our own instance of `Tput` class.
@Hywan
Copy link
Member Author

Hywan commented Oct 29, 2015

I don't know how to test Hoa\Console\Processus from a unit point of view. Functional testing would be fine but unit testing… hardcore. Any idea? /cc @jubianchi

@Hywan Hywan force-pushed the test branch 2 times, most recently from 9c0e07c to 4219c97 Compare October 29, 2015 21:56
@jubianchi
Copy link
Member

@Hywan I'll try to have a look at Processus and see if I can suggest something

@Hywan
Copy link
Member Author

Hywan commented Nov 10, 2015

Need to mock constant before completing this PR. See atoum/atoum#511. I will try a first implementation in Hoa\Test. Then, if not bad, I will port it to atoum.

@Hywan
Copy link
Member Author

Hywan commented Nov 10, 2015

Success (13 tests, 254/254 methods, 0 void method, 0 skipped method, 540 assertions)!

\o/

Since the `Window` class is a singleton, its constructor must be
private.
Instead of using hard-coded number for pointer codes, we introduce
constants:

  * `BUTTON_LEFT`,
  * `BUTTON_MIDDLE`,
  * `BUTTON_RIGHT`,
  * `BUTTON_RELEASE`,
  * `WHEEL_UP`,
  * `WHEEL_DOWN`.

These codes are the ones used by the terminal.
Instead of silently continue to loop when `stream_select` fails or timed
out, i.e. when we no longer have a mouse input, we break the loop and
untrack when `stream_select` fails. When it times out, we continue to
loop.
The first argument passed to `getOption` is a reference. Its value was
not reset each time. Now this is fixed.
The readline was previously based on `STDIN`. Now it is based on
`Console::getInput` as every other classes in the `Hoa\Console`.
1. We need it to test advanced part of the API,
2. If a system is missing it, we can fallback to this database.
As @jubianchi noticed, `setUp` runs in the parent process, no inside all
child processes. This is what we expect.
@Bhoat Bhoat merged commit 0e9a4cf into hoaproject:master Nov 10, 2015
@Hywan Hywan removed the in progress label Nov 10, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

None yet

3 participants