Skip to content

Commit d4575cb

Browse files
committed
test: adapt tests for GLPI 11
1 parent 50b91bb commit d4575cb

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

src/CarbonIntensity.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,6 @@ public function save(string $zone_name, string $source_name, array $data): int
368368
);
369369
$stmt = $DB->prepare($query);
370370

371-
$in_transaction = $DB->inTransaction() || $DB->beginTransaction();
372-
373371
foreach ($data as $intensity) {
374372
try {
375373
$stmt->bind_param(
@@ -387,9 +385,6 @@ public function save(string $zone_name, string $source_name, array $data): int
387385
continue;
388386
}
389387
}
390-
if ($in_transaction) {
391-
$DB->commit();
392-
}
393388
$stmt->close();
394389

395390
return $count;

templates/components/form/fields_macros.html.twig

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,16 @@
3333

3434
{% macro timeField(name, value, label = '', options = {}) %}
3535
{% import 'components/form/fields_macros.html.twig' as fields %}
36-
{% set options = {'rand': random()}|merge(options) %}
36+
{% set options = {
37+
'rand': random(),
38+
'disabled': false
39+
}|merge(options)
40+
%}
3741

3842
{% if options.disabled %}
3943
{% set options = options|merge({specific_tags: {'disabled': 'disabled'}}) %}
4044
{% endif %}
41-
{% if options.fields_template.isMandatoryField(name) %}
45+
{% if options.fields_template.isMandatoryField(name)|default(false) %}
4246
{% set options = {'specific_tags': {'required': true}}|merge(options) %}
4347
{% endif %}
4448

@@ -63,12 +67,15 @@
6367
{# Multiple values will be set, input need to be an array #}
6468
{% set name = "#{name}[]" %}
6569
{% endif %}
66-
{% set options = {'rand': random()}|merge(options) %}
70+
{% set options = {
71+
'rand': random(),
72+
'disabled': false}|merge(options)
73+
%}
6774
{% if options.fields_template.isMandatoryField(name)|default(false) %}
6875
{% set options = {'specific_tags': {'required': true}}|merge(options) %}
6976
{% endif %}
7077

71-
{% if options.disabled|default(false) %}
78+
{% if options.disabled %}
7279
{% set options = options|merge({specific_tags: {'disabled': 'disabled'}}) %}
7380
{% endif %}
7481

tests/src/CommonTestCase.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ protected function login($name, $password, $noauto = false)
147147
return $result;
148148
}
149149

150+
protected function logout()
151+
{
152+
Session::destroy();
153+
Session::start();
154+
}
155+
150156
/**
151157
* Get a unique random string
152158
*/
@@ -169,11 +175,11 @@ protected function getItem(string $itemtype, array $input = []): CommonDBTM
169175
{
170176
global $DB;
171177

178+
$this->handleDeprecations($itemtype, $input);
179+
172180
/** @var CommonDBTM */
173181
$item = new $itemtype();
174182

175-
$this->handleDeprecations($itemtype, $input);
176-
177183
// set random name if not already set
178184
if (!isset($item->fields['name']) && $DB->fieldExists($item->getTable(), 'name')) {
179185
if (!isset($input['name'])) {

tests/units/ProfileTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function testGetTabNameForItem()
4949
$profile = new Profile();
5050
$item = new GlpiProfile();
5151
$tabName = $profile->getTabNameForItem($item);
52-
$this->assertEquals(__('Environmental impact', 'carbon'), $tabName);
52+
$this->assertStringContainsString(__('Environmental impact', 'carbon'), $tabName);
5353
}
5454

5555
/**

0 commit comments

Comments
 (0)