Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
TestRunnerFeatures
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 1
 enableDefaultFeatures
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3/**
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; under version 2
7 * of the License (non-upgradable).
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 *
18 * Copyright (c) 2016 (original work) Open Assessment Technologies SA;
19 */
20
21namespace oat\taoDeliveryRdf\model;
22
23use oat\taoDeliveryRdf\model\event\DeliveryCreatedEvent;
24use oat\oatbox\service\ServiceManager;
25use oat\taoTests\models\runner\features\TestRunnerFeatureService;
26
27/**
28 * Event handler for Delivery Test Runner Features
29 *
30 * @author Christophe Noël <christophe@taotesting.com>
31 */
32class TestRunnerFeatures
33{
34    /**
35     * Set the default Test Runner Features for a newly created delivery
36     * xx
37     * @param DeliveryCreatedEvent $event
38     */
39    public static function enableDefaultFeatures(DeliveryCreatedEvent $event)
40    {
41        $serviceManager = ServiceManager::getServiceManager();
42        $testRunnerFeatureService = $serviceManager->get(TestRunnerFeatureService::SERVICE_ID);
43
44        $allFeatures = $testRunnerFeatureService->getAll();
45        $defaultFeatures = [];
46
47        foreach ($allFeatures as $feature) {
48            if ($feature->isEnabledByDefault() === true) {
49                $defaultFeatures[] = $feature->getId();
50            }
51        }
52
53        $delivery = new \core_kernel_classes_Resource($event->getDeliveryUri());
54        $delivery->setPropertiesValues([
55            DeliveryContainerService::TEST_RUNNER_FEATURES_PROPERTY => implode(',', $defaultFeatures)
56        ]);
57    }
58}