|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (c) 2017 Francois-Xavier Soubirou. |
|
4
|
|
|
* |
|
5
|
|
|
* This file is part of ci-report. |
|
6
|
|
|
* |
|
7
|
|
|
* ci-report is free software: you can redistribute it and/or modify |
|
8
|
|
|
* it under the terms of the GNU General Public License as published by |
|
9
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
10
|
|
|
* (at your option) any later version. |
|
11
|
|
|
* |
|
12
|
|
|
* ci-report is distributed in the hope that it will be useful, |
|
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
* GNU General Public License for more details. |
|
16
|
|
|
* |
|
17
|
|
|
* You should have received a copy of the GNU General Public License |
|
18
|
|
|
* along with ci-report. If not, see <http://www.gnu.org/licenses/>. |
|
19
|
|
|
*/ |
|
20
|
|
|
declare(strict_types=1); |
|
21
|
|
|
|
|
22
|
|
|
namespace AppBundle\DTO; |
|
23
|
|
|
|
|
24
|
|
|
use AppBundle\Entity\Project; |
|
25
|
|
|
use JMS\Serializer\Annotation\Type; |
|
26
|
|
|
use Symfony\Component\HttpFoundation\File\File; |
|
27
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
28
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Suite limits and junit files data transfert object class. |
|
32
|
|
|
* |
|
33
|
|
|
* @category ci-report app |
|
34
|
|
|
* |
|
35
|
|
|
* @author Francois-Xavier Soubirou <[email protected]> |
|
36
|
|
|
* @copyright 2017 Francois-Xavier Soubirou |
|
37
|
|
|
* @license http://www.gnu.org/licenses/ GPLv3 |
|
38
|
|
|
* |
|
39
|
|
|
* @see https://www.ci-report.io |
|
40
|
|
|
*/ |
|
41
|
|
|
class SuiteLimitsFilesDTO extends SuiteLimitsDTO |
|
42
|
|
|
{ |
|
43
|
|
|
/** |
|
44
|
|
|
* XML junit file. |
|
45
|
|
|
* |
|
46
|
|
|
* @var File |
|
47
|
|
|
* |
|
48
|
|
|
* @Type("File") |
|
49
|
|
|
* |
|
50
|
|
|
* @Assert\NotBlank( |
|
51
|
|
|
* message = "A junit file must be specified." |
|
52
|
|
|
* ) |
|
53
|
|
|
* @Assert\File( |
|
54
|
|
|
* maxSize = "1024k", |
|
55
|
|
|
* mimeTypes = {"application/xml"}, |
|
56
|
|
|
* mimeTypesMessage = "Please upload a valid XML file" |
|
57
|
|
|
* ) |
|
58
|
|
|
*/ |
|
59
|
|
|
protected $junitfile; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Constructor. |
|
63
|
|
|
* |
|
64
|
|
|
* @param Project $project |
|
65
|
|
|
* @param Request $request |
|
66
|
|
|
*/ |
|
67
|
|
|
public function __construct(Project $project, Request $request) |
|
68
|
|
|
{ |
|
69
|
|
|
$warning = $request->request->get('warning'); |
|
70
|
|
|
if (null !== $warning) { |
|
71
|
|
|
$this->setWarning((int) $warning); |
|
72
|
|
|
} else { |
|
73
|
|
|
$this->setWarning($project->getWarning()); |
|
74
|
|
|
} |
|
75
|
|
|
$success = $request->request->get('success'); |
|
76
|
|
|
if (null !== $success) { |
|
77
|
|
|
$this->setSuccess((int) $success); |
|
78
|
|
|
} else { |
|
79
|
|
|
$this->setSuccess($project->getSuccess()); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
$file = $request->files->get('junitfile'); |
|
83
|
|
|
if (null !== $file) { |
|
84
|
|
|
$this->setJunitfile($file); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Set junit xml file. |
|
90
|
|
|
* |
|
91
|
|
|
* @param File $file |
|
92
|
|
|
* |
|
93
|
|
|
* @return SuiteLimitsFilesDTO |
|
94
|
|
|
*/ |
|
95
|
|
|
public function setJunitfile(File $file): self |
|
96
|
|
|
{ |
|
97
|
|
|
$this->junitfile = $file; |
|
98
|
|
|
|
|
99
|
|
|
return $this; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Get junit xml file. |
|
104
|
|
|
* |
|
105
|
|
|
* @return File |
|
106
|
|
|
*/ |
|
107
|
|
|
public function getJunitfile(): ?File |
|
108
|
|
|
{ |
|
109
|
|
|
return $this->junitfile; |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|