peridot-php/peridot-dsl-example

Got Some Problem with Scope

Jnoack331 opened this issue ยท 4 comments

I just cant get this working and i saw that all of the Tests share there scopes, cause of that the acceptanceDslTitle is overwritten every time and the last one is used. For the example it would be Then. What am i doing wrong?

Console output:

Scenario:
  Then the Url to the Login Page
  Then i look up 127.0.0.1:8000
  Then i get redirected

Hey, sorry you're having trouble. This is possibly related to peridot-php/peridot#174. The current scope implementation has some problems that we're hoping to address in future versions.

@brianium might have some pointers that could help here. I assume this example worked at some point, so knowing when it stopped working would be really valuable when we fix scopes once and for all.

FWIW, this doesn't necessarily preclude a custom DSL from working "well enough". For example, here's a custom DSL that is in use right now, and working fine.

The example worked at no point but i know the error at:

AbstractTest.php:

/**
 * {@inheritdoc}
 *
 * @param  TestInterface $parent
 * @return mixed|void
 */
public function setParent(TestInterface $parent)
{
    $this->parent = $parent;
    $this->setScope($parent->getScope());
}

It sets the scope of parent but then they are all overwriting each other cause all have the same parent. Or am i wrong? :)

Scopes in Peridot are meant to inherit from their parent scope, but allow shadowing (overriding) of scope properties. In my understanding, it's supposed to simulate prototypical inheritance like you would normally have in an equivalent JavaScript test runner.

The bug you've encountered seems to have something to do with how the shadowing is implemented. For now, this example repo is definitely not working as intended.

The current implementation is over at peridot-php/peridot-scope if you want to dig deeper.

When I said that this probably worked at some point, I meant that it assumedly worked at the time that the original author wrote the code. But unfortunately, even by manually changing the Peridot version in composer.json I only found versions of Peridot where it's broken in different ways.

For reference, the titles display correctly under Peridot 1.5.0, but I get an error about Scope property cwd not found. Past 1.5.0, everything is green but all the titles start with Then, as in your example.

Ok thanks for your explanation. I am using the standart dsl now, i will look at the peridot-scope repo later. ๐Ÿ‘