Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / EventDispatcher / Tester / EventDispatchingFeatureTester.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\AfterFeatureSetup;
14 use Behat\Behat\EventDispatcher\Event\AfterFeatureTested;
15 use Behat\Behat\EventDispatcher\Event\BeforeFeatureTeardown;
16 use Behat\Behat\EventDispatcher\Event\BeforeFeatureTested;
17 use Behat\Testwork\Environment\Environment;
18 use Behat\Testwork\Tester\Result\TestResult;
19 use Behat\Testwork\Tester\SpecificationTester;
20 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
21
22 /**
23  * Feature tester dispatching BEFORE/AFTER events during tests.
24  *
25  * @author Konstantin Kudryashov <ever.zet@gmail.com>
26  */
27 final class EventDispatchingFeatureTester implements SpecificationTester
28 {
29     /**
30      * @var SpecificationTester
31      */
32     private $baseTester;
33     /**
34      * @var EventDispatcherInterface
35      */
36     private $eventDispatcher;
37
38     /**
39      * Initializes tester.
40      *
41      * @param SpecificationTester      $baseTester
42      * @param EventDispatcherInterface $eventDispatcher
43      */
44     public function __construct(SpecificationTester $baseTester, EventDispatcherInterface $eventDispatcher)
45     {
46         $this->baseTester = $baseTester;
47         $this->eventDispatcher = $eventDispatcher;
48     }
49
50     /**
51      * {@inheritdoc}
52      */
53     public function setUp(Environment $env, $feature, $skip)
54     {
55         $event = new BeforeFeatureTested($env, $feature);
56         $this->eventDispatcher->dispatch($event::BEFORE, $event);
57
58         $setup = $this->baseTester->setUp($env, $feature, $skip);
59
60         $event = new AfterFeatureSetup($env, $feature, $setup);
61         $this->eventDispatcher->dispatch($event::AFTER_SETUP, $event);
62
63         return $setup;
64     }
65
66     /**
67      * {@inheritdoc}
68      */
69     public function test(Environment $env, $feature, $skip)
70     {
71         return $this->baseTester->test($env, $feature, $skip);
72     }
73
74     /**
75      * {@inheritdoc}
76      */
77     public function tearDown(Environment $env, $feature, $skip, TestResult $result)
78     {
79         $event = new BeforeFeatureTeardown($env, $feature, $result);
80         $this->eventDispatcher->dispatch($event::BEFORE_TEARDOWN, $event);
81
82         $teardown = $this->baseTester->tearDown($env, $feature, $skip, $result);
83
84         $event = new AfterFeatureTested($env, $feature, $result, $teardown);
85         $this->eventDispatcher->dispatch($event::AFTER, $event);
86
87         return $teardown;
88     }
89 }