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

defaultAsserter as static leading to problems?? #6

Closed
flip111 opened this issue Feb 15, 2014 · 6 comments
Closed

defaultAsserter as static leading to problems?? #6

flip111 opened this issue Feb 15, 2014 · 6 comments
Assignees
Labels

Comments

@flip111
Copy link

flip111 commented Feb 15, 2014

Hi,

I'm running two tests. Each test has it's own Ruler, but i think that both rulers share the same Asserter because it is declared as static in the ruler class. This leads to operators being available in the second ruler which where defined in the first ruler.

A workaround would be to use the new getOperators() method to get all the operators. And then call setOperator with value null on them. But this is not so nice to do it this way.

@Hywan
Copy link
Member

Hywan commented Feb 18, 2014

Hello :-),

The default asserter is… the default asserter. Please, use setAsserter with a new asserter for your test:

$ruler = new Hoa\Ruler\Ruler();

$rule = '…';
$context = new Hoa\Ruler\Context();
$context[…] = …;

$asserter = new Hoa\Ruler\Visitor\Asserter($context);
$ruler->setAsserter($asserter);

$ruler->assert($rule, $context);

The default asserter is present to only simplify common usage.

@Hywan Hywan added the question label Feb 18, 2014
@Hywan Hywan self-assigned this Feb 18, 2014
@Hywan
Copy link
Member

Hywan commented Feb 21, 2014

Is it ok for you?

@flip111
Copy link
Author

flip111 commented Feb 21, 2014

Sorry i didn't have time to work again on my library and verify this solution + add readme as requested in #2

@flip111
Copy link
Author

flip111 commented Feb 22, 2014

I'm a bit confused here. When making a new Asserter no context is required https://github.com/hoaproject/Ruler/blob/master/Visitor/Asserter.php#L91 but when getting the set Asserter from the ruler you explicitly must give the context https://github.com/hoaproject/Ruler/blob/master/Ruler.php#L184

Please make setting the context optional when getting the Asserter from the ruler ... If that is also possible to change then your solution works !!

@Hywan
Copy link
Member

Hywan commented Feb 24, 2014

965afb7 done :-).

@Hywan Hywan closed this as completed Feb 24, 2014
@flip111
Copy link
Author

flip111 commented Feb 24, 2014

Thx!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

2 participants