summaryrefslogtreecommitdiffstats
path: root/pts-core/objects/pts_test_suite_details.php
blob: 5041d553f46c6b7baee72f01de96e10770a63b76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php

/*
	Phoronix Test Suite
	URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/
	Copyright (C) 2008, Phoronix Media
	Copyright (C) 2008, Michael Larabel

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

class pts_test_suite_details
{
	var $identifier;
	var $identifier_show_prefix;
	var $name;
	var $maintainer;
	var $description;
	var $version;
	var $type;
	var $test_type;
	var $unique_tests;
	var $only_partially_supported = false;

	public function __construct($identifier)
	{
		$xml_parser = new pts_suite_tandem_XmlReader($identifier);
		$this->identifier = $identifier;
		$this->name = $xml_parser->getXMLValue(P_SUITE_TITLE);
		$this->test_type = $xml_parser->getXMLValue(P_SUITE_TYPE);
		$this->version = $xml_parser->getXMLValue(P_SUITE_VERSION);
		$this->type = $xml_parser->getXMLValue(P_SUITE_TYPE);
		$this->maintainer = $xml_parser->getXMLValue(P_SUITE_MAINTAINER);
		$this->description = $xml_parser->getXMLValue(P_SUITE_DESCRIPTION);
		$this->unique_tests = count(pts_contained_tests($identifier));

		$suite_support_code = pts_suite_supported($identifier);

		$this->identifier_show_prefix = " ";
		if($suite_support_code > 0)
		{
			if($suite_support_code == 1)
			{
				$this->identifier_show_prefix = "*";
				$this->only_partially_supported = true;
			}
		}
	}
	public function partially_supported()
	{
		return $this->only_partially_supported;
	}
	public function info_string()
	{
		$str = "\n";

		$suite_maintainer = explode("|", $this->maintainer);
		if(count($suite_maintainer) == 2)
		{
			$suite_maintainer = trim($suite_maintainer[0]) . " <" . trim($suite_maintainer[1]) . ">";
		}
		else
		{
			$suite_maintainer = $suite_maintainer[0];
		}

		$str .= "Suite Version: " . $this->version . "\n";
		$str .= "Maintainer: " . $this->maintainer . "\n";
		$str .= "Suite Type: " . $this->test_type . "\n";
		$str .= "Unique Tests: " . $this->unique_tests . "\n";
		$str .= "Suite Description: " . $this->description . "\n";
		$str .= "\n";

		pts_print_format_tests($this->identifier, $str);

		return $str;
	}
	public function __toString()
	{
		$str = "";

		if(IS_DEBUG_MODE)
		{
			$str = sprintf("%-26ls - %-32ls %-4ls  %-12ls\n", $this->identifier_show_prefix . " " . $this->identifier, $this->name, $this->version, $this->type);
		}
		else if(!empty($this->name))
		{
			$str = sprintf("%-24ls - %-32ls [Type: %s]\n", $this->identifier_show_prefix . " " . $this->identifier, $this->name, $this->test_type);
		}

		return $str;
	}
}

?>