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

display proposition of assert when Atoum's exception is raised #42

Closed
vonglasow opened this issue Dec 20, 2011 · 3 comments
Closed

display proposition of assert when Atoum's exception is raised #42

vonglasow opened this issue Dec 20, 2011 · 3 comments

Comments

@vonglasow
Copy link
Member

like we have when we try to use wrong parameter in CLI

php mageekguy.atoum.phar --namespace
Error: Argument '--namespace' is unknown, did you mean '--namespaces' ?

We can have a proposition

Error: Assertion 'sting' is unknown, did you mean 'string' ?

See example

avonglasow@dev-alex:~/project/helloworld$ php tests/units/helloWorld.php 
> atoum version nightly-844-201112021413 by Frédéric Hardy (phar:///home/avonglasow/project/helloworld/tests/mageekguy.atoum.phar)
> PHP path: /usr/bin/php5
> PHP version:
=> PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cli) (built: Jun 28 2011 13:13:26)
=> Copyright (c) 1997-2009 The PHP Group
=> Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
=>     with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
=>     with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
> vendor\project\tests\units\helloWorld...
[E___________________________________________________________][1/1]
=> Test duration: 0.00 second.
=> Memory usage: 0.00 Mb.
> Total test duration: 0.00 second.
> Total test memory usage: 0.00 Mb.
> Running duration: 0.59 second.
Failure (1 test, 1/1 method, 0 failure, 0 error, 1 exception) !
> There is 1 exception:
=> vendor\project\tests\units\helloWorld::testSay():
==> Exception throwed in file /home/avonglasow/project/helloworld/tests/units/helloWorld.php on line 19:
==> exception 'mageekguy\atoum\exceptions\logic\invalidArgument' with message 'Asserter 'mageekguy\atoum\asserters\sting' does not exist' in phar:///home/avonglasow/project/helloworld/tests/mageekguy.atoum.phar/classes/asserter/generator.php:32
==> Stack trace:
==> #0 phar:///home/avonglasow/project/helloworld/tests/mageekguy.atoum.phar/classes/asserter/generator.php(65): mageekguy\atoum\asserter\generator->__get('sting')
==> #1 /home/avonglasow/project/helloworld/tests/units/helloWorld.php(19): mageekguy\atoum\asserter\generator->__call('sting', Array)
==> #2 /home/avonglasow/project/helloworld/tests/units/helloWorld.php(19): mageekguy\atoum\asserter\generator->sting('Hello World!')
==> #3 phar:///home/avonglasow/project/helloworld/tests/mageekguy.atoum.phar/classes/test.php(539): vendor\project\tests\units\helloWorld->testSay()
==> #4 -(1): mageekguy\atoum\test->runTestMethod('testSay')
==> #5 {main}
Error: Assertion 'sting' is unknown, did you mean 'string' ?
@mageekguy
Copy link
Contributor

I think that it's impossible to do that, even if the idea is very interesting.
The autoload is used to locate asserter, so to do that, the autoload must read all file in each classes directories, parse it and try to match each class name.
And it seems to me just overkill ;).

@vonglasow
Copy link
Member Author

Ok, like this. But i think you need to have a list of assertions to be able to generate the documentation. Isn't possible to use the list of assertion, generated for the documentation, to made the matching between the assertion written and the real assertion.

Like this you just need to use the Exception raised to catch the assertion and compare with the list of assertion already generated.

@mageekguy
Copy link
Contributor

I have no list of assertion for documentation, and moreover, the user can add his own assertion, so your solution is not a solution ;).

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

No branches or pull requests

2 participants