Coder Social home page Coder Social logo

Comments (13)

driesvints avatar driesvints commented on June 10, 2024 1

No

from framework.

taylorotwell avatar taylorotwell commented on June 10, 2024 1

Seems that way? PRs welcome 🤘

from framework.

gmaccario avatar gmaccario commented on June 10, 2024 1

@yourchocomate As I said, I was trying the example on the official documentation, which currently looks different compared to a week ago. I leave you the old version here https://web.archive.org/web/20240312151913/https://laravel.com/docs/11.x/console-tests

from framework.

yourchocomate avatar yourchocomate commented on June 10, 2024 1

Ahh!! I see.. That was a mistake from the doc🥸

from framework.

driesvints avatar driesvints commented on June 10, 2024

That's an odd one... I get the same thing. From what I can gather in the code I don't think it's possible to assert output after it's been asserted once.

from framework.

github-actions avatar github-actions commented on June 10, 2024

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

from framework.

gmaccario avatar gmaccario commented on June 10, 2024

Thank you @driesvints for your reply. Is there currently any workaround?

from framework.

gmaccario avatar gmaccario commented on June 10, 2024

OK thank you. So basically a command that contains a choice instruction is not testable right now?

from framework.

gcjbr avatar gcjbr commented on June 10, 2024

I found the issue, but don't understand mockery enough to fix it.

Tried for a couple hours by failed :(

If anyone wants to give it a poke:

On PendingCommand we check for askQuestion types of commands and clean the expectedQuestions array as we go.

Same should be done for writeln type of commands.

The gist of it is, at the end of the assertions, PendingCommand will call run() and fail if any of the arrays if things you wanna very is not empty.

Verification is done previously by mockConsoleOutput(), as I meantioned.

Something like:

`

 $mock = Mockery::mock(OutputStyle::class.'[askQuestion, writeln]', [
        new ArrayInput($this->parameters), $this->createABufferedOutputMock(),
    ]);


    foreach ($this->test->expectedOutputSubstrings as $substring) {
        $mock->shouldReceive('writeln')
            ->once()
            ->with(Mockery::type('string'), Mockery::type('int'))
            ->andReturnUsing(function ($text) {
                return $text;
            });

    }`

If anyone try it they'll see where I got stuck with Mockery.

from framework.

yourchocomate avatar yourchocomate commented on June 10, 2024

@gmaccario Can you clarify what you are expecting or what should be th expected behaviour?

Cause the order you have provided can't be valid as,

you already expecting an exact output by clarifying expectsOutput('Your name is Taylor Otwell and you prefer PHP.')
again it would be unnecessary - also the assertion will not happen for doesntExpectOutput()

from framework.

gmaccario avatar gmaccario commented on June 10, 2024

@yourchocomate I tried the example in the official documentation https://laravel.com/docs/11.x/console-tests

from framework.

yourchocomate avatar yourchocomate commented on June 10, 2024

@yourchocomate I tried the example in the official documentation https://laravel.com/docs/11.x/console-tests

Okay! But asserting expectsOutputToContain() after expectsOutput('some text') will lead to fail in test as you're already expecting for a specific output rather than a portion

from framework.

driesvints avatar driesvints commented on June 10, 2024

Just gonna close this one right now as not supported, sorry.

from framework.

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.