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

[Bug?]: Parse error #1

Open
JacquesDurand opened this issue May 6, 2022 · 3 comments
Open

[Bug?]: Parse error #1

JacquesDurand opened this issue May 6, 2022 · 3 comments

Comments

@JacquesDurand
Copy link

Hi !
I recently stumbled upon Approval testing and am very glad some people made a library for it in php, thank you for that !

I am currently trying (for a class project) to upgrade a legacy application ( php 5.6, symfony 3.1) which contains a few controllers and wanted to setup approval tests before trying to upgrade/refacto the existing code base.

I ended up with the following error while trying to setup a simple test (your given example actually):

Parse error: syntax error, unexpected ':', expecting ';' or '{' in .../vendor/approvals/approval-tests/src/Namers/PHPUnitNamer.php on line 71

My Test Case is the following:

<?php

namespace Tests\Approvals\Controller;

use ApprovalTests\Approvals;
use PHPUnit\Framework\TestCase;

class DefaultControllerTest extends TestCase
{
    public function testList()
    {
        $list = ['zero', 'one', 'two', 'three', 'four', 'five'];
        Approvals::verifyList($list);
    }

//    public function testIndex()
//    {
//        $client = static::createClient();
//
//        $crawler = $client->request('GET', '/');
//
//        $response = (array) $client->getResponse();
//        Approvals::verifyAsJson($response);
//    }

}

And even the simple testList() returns the error mentioned earlier.
If it is any help, I am working through docker with a custom image of php-fpm-5.6-alpine, phpunit is at 5.7 version.

Thanks in advance and if you need any more details I would happily provide !

@vansari
Copy link

vansari commented Nov 29, 2022

Hi @JacquesDurand

it seems that the return type of __toString is the reason of your issue. I opened a MR which can easily "fix" this problem.
BTW: Why do you work with PHP 5.6 in 2022?

#3

@JacquesDurand
Copy link
Author

Hi @vansari , thank you for responding and taking the time to have a look !
I actually do not work with PHP 5.6 on a day to day basis (and I am glad I don't have to), it was the specific goal of a school project to upgrade an old application to a more recent version ;)

@ilyaguy
Copy link

ilyaguy commented Mar 13, 2023

BTW: Why do you work with PHP 5.6 in 2022?

Now it is 2023, but project is on PHP 5.6. It is without any tests, so I want to cover it with tests, then upgrade at least to 7.x. :)

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

3 participants