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

Merge 0.13 #698

Merged
merged 28 commits into from
Jul 9, 2020
Merged

Merge 0.13 #698

merged 28 commits into from
Jul 9, 2020

Conversation

mcg-web
Copy link
Member

@mcg-web mcg-web commented Jul 8, 2020

No description provided.

sgehrig and others added 23 commits July 8, 2020 09:25
Changes setup of expression language functions to fix issue overblog#588
…PrivateProperties0.12"

This reverts commit 6433464, reversing
changes made to 7155466.
cherry-pick commits from original overblog#675 fix proposed for 0.13
@mcg-web mcg-web marked this pull request as ready for review July 8, 2020 21:25
@mcg-web mcg-web requested a review from murtukov July 8, 2020 21:25
@murtukov
Copy link
Member

murtukov commented Jul 8, 2020

@mcg-web

In the PR #682 I introduces the TypeGenerator::GLOBAL_VARS constant to replace all hard-coded strings globalVariables in the whole project.

2 things here have to be done:

  1. Replace all hardcoded globalVariables everywhere, for example.

    replace this

    $arguments['globalVariables']->get('container')->getParameter($paramName) 

    with this

    use Overblog\GraphQLBundle\Generator\TypeGenerator as Generator;
    
    $arguments[Generator::GLOBAL_VARS]->get('container')->getParameter($paramName) 
  2. There are many places in the tests directory, where the eval() function is used. It's important, that the variable name is the same, so you need for example change this:

    public function testGetUserNoTokenStorage(): void
        {
            $globalVariable = new GlobalVariables(['security' => new Security($this->createMock(CoreSecurity::class))]);
            $globalVariable->get('security');
            $this->assertNull(eval($this->getCompileCode()));
        }

    with this

    public function testGetUserNoTokenStorage(): void
        {
           ${Generator::GLOBAL_VARS} = new GlobalVariables(['security' => new Security($this->createMock(CoreSecurity::class))]);
           ${Generator::GLOBAL_VARS}->get('security');
           $this->assertNull(eval($this->getCompileCode()));
        }

Take into account, that $this->globalVars usually contains a string with a leading dollar ("$globalVariables") and the constant is without the dollar ("globalVariables")

@mcg-web
Copy link
Member Author

mcg-web commented Jul 9, 2020

done @murtukov !

@murtukov
Copy link
Member

murtukov commented Jul 9, 2020

@mcg-web

It wasn't really necessary to use TypeGenerator::GLOBAL_VARS on the right side with the $expressionLanguage->evaluate calls:

${TypeGenerator::GLOBAL_VARS} = new GlobalVariables(['container' => $this->getDIContainerMock(['toto' => $object])]);
$this->expressionLanguage->evaluate($name.'("toto")', [TypeGenerator::GLOBAL_VARS => ${TypeGenerator::GLOBAL_VARS}])

because you explicitely pass the variable inside the evaluate method. So it could for example be just:

$vars = new GlobalVariables(['container' => $this->getDIContainerMock(['toto' => $object])]);
$this->expressionLanguage->evaluate($name.'("toto")', [TypeGenerator::GLOBAL_VARS => $vars])

The variable name only matters when you use the built-in eval function, because it takes the variables from outer scope, like in this example:

${Generator::GLOBAL_VARS} = new GlobalVariables(['security' => new Security($this->createMock(CoreSecurity::class))]);
$this->assertNull(eval($this->getCompileCode()));

@murtukov
Copy link
Member

murtukov commented Jul 9, 2020

@mcg-web LGTM

@mcg-web mcg-web merged commit 6534df6 into overblog:master Jul 9, 2020
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

Successfully merging this pull request may close these issues.

4 participants