Passed
Branch develop (7b8a20)
by
unknown
32:48
created

MyObjectTest::assertPreConditions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
/* Copyright (C) 2007-2017 Laurent Destailleur  <[email protected]>
3
 * Copyright (C) ---Put here your own copyright and developer email---
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17
 */
18
19
/**
20
 * \file    test/phpunit/MyObjectTest.php
21
 * \ingroup mymodule
22
 * \brief   PHPUnit test for MyObject class.
23
 */
24
25
global $conf,$user,$langs,$db;
26
//define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
27
//require_once 'PHPUnit/Autoload.php';
28
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
29
require_once dirname(__FILE__).'/../../htdocs/mymodule/class/myobject.class.php';
30
31
if (empty($user->id)) {
32
	print "Load permissions for admin user nb 1\n";
33
	$user->fetch(1);
34
	$user->getrights();
35
}
36
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
37
38
$langs->load("main");
39
40
41
/**
42
 * Class MyObjectTest
43
 * @package Testmymodule
44
 */
45
class MyObjectTest extends \PHPUnit_Framework_TestCase
46
{
47
	protected $savconf;
48
	protected $savuser;
49
	protected $savlangs;
50
	protected $savdb;
51
52
	/**
53
	 * Constructor
54
	 * We save global variables into local variables
55
	 *
56
	 * @return BOMTest
0 ignored issues
show
Bug introduced by
The type BOMTest was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
57
	 */
58
	public function __construct()
59
	{
60
		parent::__construct();
61
62
		//$this->sharedFixture
63
		global $conf,$user,$langs,$db;
64
		$this->savconf=$conf;
65
		$this->savuser=$user;
66
		$this->savlangs=$langs;
67
		$this->savdb=$db;
68
69
		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
70
		//print " - db ".$db->db;
71
		print "\n";
72
	}
73
74
	/**
75
	 * Global test setup
76
	 * @return void
77
	 */
78
	public static function setUpBeforeClass()
79
	{
80
		global $conf,$user,$langs,$db;
81
		$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
82
83
		print __METHOD__."\n";
84
	}
85
86
	/**
87
	 * Unit test setup
88
	 * @return void
89
	 */
90
	protected function setUp()
91
	{
92
		global $conf,$user,$langs,$db;
93
		$conf=$this->savconf;
94
		$user=$this->savuser;
95
		$langs=$this->savlangs;
96
		$db=$this->savdb;
97
98
		print __METHOD__."\n";
99
	}
100
101
	/**
102
	 * Unit test teardown
103
	 * @return void
104
	 */
105
	protected function tearDown()
106
	{
107
		print __METHOD__."\n";
108
	}
109
110
	/**
111
	 * Global test teardown
112
	 * @return void
113
	 */
114
	public static function tearDownAfterClass()
115
	{
116
		global $conf,$user,$langs,$db;
117
		$db->rollback();
118
119
		print __METHOD__."\n";
120
	}
121
122
123
	/**
124
	 * A sample test
125
	 * @return bool
126
	 */
127
	public function testSomething()
128
	{
129
		global $conf,$user,$langs,$db;
130
		$conf=$this->savconf;
131
		$user=$this->savuser;
132
		$langs=$this->savlangs;
133
		$db=$this->savdb;
134
135
		$result = true;
136
137
		print __METHOD__." result=".$result."\n";
138
		$this->assertTrue($result);
139
140
		return $result;
141
	}
142
}
143