Issues (36)

views/testing/index.php (2 issues)

Severity
1
<?php
2
3
use yii\grid\GridView;
4
use carono\exchange1c\widgets\TestingGridView;
5
use yii\helpers\Html;
6
use yii\data\ArrayDataProvider;
7
use carono\exchange1c\widgets\Panel;
8
9
/**
10
 * @var \yii\web\View $this
11
 * @var \carono\exchange1c\models\TestingClass $testingClass
12
 * @var \carono\exchange1c\models\TestingClass $resultClass
13
 */
14
$this->title = 'Тестирование модуля';
15
echo Html::tag('div', 'В разработке', ['class' => 'alert alert-danger']);
16
if (YII_ENV_PROD) {
17
    ?>
18
    <div class="alert alert-danger">
19
        Проводить тестирование в окружении YII_ENV_PROD невозможно.
20
    </div>
21
    <?php
22
    return;
23
}
24
25
?>
26
    <div class="alert alert-warning">
27
        Внимание! Будет происходить тестирование вашей реализации методов.
28
    </div>
29
<?php
30
31
$links = [
32
    'groupClass' => ['testing/index', 'class' => 'TestingGroupClass'],
33
    'productClass' => ['testing/index', 'class' => 'TestingProductClass'],
34
    'documentClass' => ['testing/index', 'class' => 'TestingDocumentClass'],
35
    'partnerClass' => ['testing/index', 'class' => 'TestingPartnerClass'],
36
];
37
?>
38
    <div class="panel">
39
        <div class="btn-group panel-body">
40
            <?php
41
            foreach ($links as $name => $link) {
42
                echo Html::a($name, $link, ['class' => 'btn btn-primary']);
43
            }
44
            ?>
45
        </div>
46
    </div>
47
48
49
<?php
50
if (!$testingClass) {
0 ignored issues
show
$testingClass is of type carono\exchange1c\models\TestingClass, thus it always evaluated to true.
Loading history...
51
    return;
52
}
53
54
$transaction = Yii::$app->db->beginTransaction();
55
56
Panel::begin();
57
$testingProductClass = $testingClass::testImplementsClass();
58
59
60
echo TestingGridView::widget([
61
    'formatter' => [
62
        'class' => \yii\i18n\Formatter::class,
63
        'nullDisplay' => ''
64
    ],
65
    'caption' => $testingClass->caption,
66
    'dataProvider' => new ArrayDataProvider(['allModels' => $testingClass::findAll()]),
67
]);
68
69
Panel::end();
70
71
if ($resultClass) {
0 ignored issues
show
$resultClass is of type carono\exchange1c\models\TestingClass, thus it always evaluated to true.
Loading history...
72
    Panel::begin();
73
    $result = $resultClass->getResult();
74
    if (is_array($result)) {
75
        echo GridView::widget(['dataProvider' => new ArrayDataProvider(['allModels' => $result])]);
76
    } elseif (is_string($result)) {
77
        echo $result;
78
    } elseif (is_object($result)) {
79
        echo \yii\widgets\DetailView::widget(['model' => $result]);
80
    } else {
81
        var_dump($result);
82
    }
83
    Panel::end();
84
}
85
86
$transaction->rollBack();