Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / EventDispatcher / Tester / EventDispatchingOutlineTester.php
1 <?php
2
3 /*
4  * This file is part of the Behat.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 namespace Behat\Behat\EventDispatcher\Tester;
12
13 use Behat\Behat\EventDispatcher\Event\AfterOutlineSetup;
14 use Behat\Behat\EventDispatcher\Event\AfterOutlineTested;
15 use Behat\Behat\EventDispatcher\Event\BeforeOutlineTeardown;
16 use Behat\Behat\EventDispatcher\Event\BeforeOutlineTested;
17 use Behat\Behat\Tester\OutlineTester;
18 use Behat\Gherkin\Node\FeatureNode;
19 use Behat\Gherkin\Node\OutlineNode;
20 use Behat\Testwork\Environment\Environment;
21 use Behat\Testwork\Tester\Result\TestResult;
22 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
23
24 /**
25  * Outline tester dispatching BEFORE/AFTER events during tests.
26  *
27  * @author Konstantin Kudryashov <ever.zet@gmail.com>
28  */
29 final class EventDispatchingOutlineTester implements OutlineTester
30 {
31     /**
32      * @var OutlineTester
33      */
34     private $baseTester;
35     /**
36      * @var EventDispatcherInterface
37      */
38     private $eventDispatcher;
39
40     /**
41      * Initializes tester.
42      *
43      * @param OutlineTester            $baseTester
44      * @param EventDispatcherInterface $eventDispatcher
45      */
46     public function __construct(OutlineTester $baseTester, EventDispatcherInterface $eventDispatcher)
47     {
48         $this->baseTester = $baseTester;
49         $this->eventDispatcher = $eventDispatcher;
50     }
51
52     /**
53      * {@inheritdoc}
54      */
55     public function setUp(Environment $env, FeatureNode $feature, OutlineNode $outline, $skip)
56     {
57         $event = new BeforeOutlineTested($env, $feature, $outline);
58         $this->eventDispatcher->dispatch($event::BEFORE, $event);
59
60         $setup = $this->baseTester->setUp($env, $feature, $outline, $skip);
61
62         $event = new AfterOutlineSetup($env, $feature, $outline, $setup);
63         $this->eventDispatcher->dispatch($event::AFTER_SETUP, $event);
64
65         return $setup;
66     }
67
68     /**
69      * {@inheritdoc}
70      */
71     public function test(Environment $env, FeatureNode $feature, OutlineNode $outline, $skip)
72     {
73         return $this->baseTester->test($env, $feature, $outline, $skip);
74     }
75
76     /**
77      * {@inheritdoc}
78      */
79     public function tearDown(Environment $env, FeatureNode $feature, OutlineNode $outline, $skip, TestResult $result)
80     {
81         $event = new BeforeOutlineTeardown($env, $feature, $outline, $result);
82         $this->eventDispatcher->dispatch($event::BEFORE_TEARDOWN, $event);
83
84         $teardown = $this->baseTester->tearDown($env, $feature, $outline, $skip, $result);
85
86         $event = new AfterOutlineTested($env, $feature, $outline, $result, $teardown);
87         $this->eventDispatcher->dispatch($event::AFTER, $event);
88
89         return $teardown;
90     }
91 }