Giter VIP home page Giter VIP logo

Comments (9)

stof avatar stof commented on July 16, 2024

instead of forcing to customize WebAssert (which also means we will never be able to add new kinds of failures in the proposed API as that would break BC for your callback), a cleaner solution would be to use the dedicated PHPUnit feature to handle some exceptions as failures.

See https://github.com/minkphp/driver-testsuite/blob/af6107c1f16f4c43c19ea162e0da88d55c6cf21a/tests/TestCase.php#L74-L81 where our driver testsuite uses that hook to mark tests as skipped instead of errored when a Behat\Mink\Exception\UnsupportedDriverActionException exception is thrown. You could do the same to turn Behat\Mink\Exception\ExpectationException into a failure instead

from mink.

alexpott avatar alexpott commented on July 16, 2024

Yes but doing that means re-throwing the exception from the onNotSuccessful and therefore changing the exception type. We have tried to propose changes to PHPUnit to facilitate this see sebastianbergmann/phpunit#4983 (comment)

Atm if we want to mark Mink exceptions as PHPUnit failures we have do something like:


    if ($t instanceof MinkException) {
      $e = new AssertionFailedError($t->getMessage(), $t->getCode(), $t);
      $trace = $t->getTrace();
      foreach ($trace as $i => $call) {
        unset($trace[$i]['args']);
      }
      $reflection = new \ReflectionProperty($e, 'serializableTrace');
      $reflection->setValue($e, $trace);
      throw $e;
    }

in order to preserve the trace. Which in my mind not very sensible.

from mink.

stof avatar stof commented on July 16, 2024

AFAIU, the need for this complex code is caused by AssertionFailedError loosing the chained exception when serializing it for process isolation. I would rather work on fixing that in PHPUnit (as chaining exceptions was the suggested solution in sebastianbergmann/phpunit#4983 (comment))

from mink.

mondrake avatar mondrake commented on July 16, 2024

I have filed sebastianbergmann/phpunit#5068 which, I think, would solve the trace issue while using the solution proposed here in #835 (comment) which seems to me the cleanest one.

from mink.

mondrake avatar mondrake commented on July 16, 2024

PHPUnit rejected sebastianbergmann/phpunit#5069 and will not pursue sebastianbergmann/phpunit#5068.

from mink.

stof avatar stof commented on July 16, 2024

Well, if he decided that mapping the details is the way to go, he should probably bundle an utility in PHPUnit to make it easy to copy the trace, given the hacks it requires. but that should be discussed with PHPUnit, as that's clearly a PHPUnit limitation here.

The proposal done here adds lots of complexity in Mink and means that we cannot add new assertions outside of major versions as it would change the requirements for that callback.

from mink.

mondrake avatar mondrake commented on July 16, 2024

Alright, I understand the position here. I will try something else on Drupal side, before calling time of death. Thanks

from mink.

stof avatar stof commented on July 16, 2024

sebastianbergmann/phpunit#5201 might allow to solve the root cause without the need for this weird feature request. So you can subscribe to that issue.

from mink.

mondrake avatar mondrake commented on July 16, 2024

Thanks for the pointer, subscribed there.

I’d say what’s weird here could be the solution - the feature request per se is quite sensible.

from mink.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.