ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilMailAddressTypesTest Class Reference
+ Inheritance diagram for ilMailAddressTypesTest:
+ Collaboration diagram for ilMailAddressTypesTest:

Public Member Functions

 setUp ()
 
 testFactoryShouldReturnShouldReturnProperAddressType (ilMailAddress $address, $expectedAddressType, callable $preRunCallback=null)
 addressTypes More...
 
 addressTypes ()
 

Protected Member Functions

 setGlobalVariable ($name, $value)
 

Detailed Description

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de

Definition at line 18 of file ilMailAddressTypesTest.php.

Member Function Documentation

◆ addressTypes()

ilMailAddressTypesTest::addressTypes ( )
Returns
array

Definition at line 69 of file ilMailAddressTypesTest.php.

References $result, and array.

70  {
71  $that = $this;
72 
73  return [
74  array(new ilMailAddress('#il_ml_4711', ''), 'ilMailMailingListAddressType'),
75  array(new ilMailAddress('#MyGroup', ''), 'ilMailGroupAddressType', function() use ($that) {
76  $database = $that->getMockBuilder('ilDBInterface')->getMock();
77  $result = $that->getMockBuilder('ilDBStatement')->getMock();
78  $result->expects($that->any())->method('numRows')->will($that->returnValue(1));
79  $database->expects($that->any())->method('query')->will($that->returnValue($result));
80  $that->setGlobalVariable('ilDB', $database);
81  }),
82  array(new ilMailAddress('#MyGroup', 'ilias'), 'ilMailGroupAddressType', function() use ($that) {
83  $database = $that->getMockBuilder('ilDBInterface')->getMock();
84  $result = $that->getMockBuilder('ilDBStatement')->getMock();
85  $result->expects($that->any())->method('numRows')->will($that->returnValue(1));
86  $database->expects($that->any())->method('query')->will($that->returnValue($result));
87  $that->setGlobalVariable('ilDB', $database);
88  }),
89  array(new ilMailAddress('phpunit', ''), 'ilMailLoginOrEmailAddressAddressType'),
90  array(new ilMailAddress('phpunit', 'ilias'), 'ilMailLoginOrEmailAddressAddressType'),
91  array(new ilMailAddress('phpunit', 'ilias.de'), 'ilMailLoginOrEmailAddressAddressType'),
92  array(new ilMailAddress('#member', 'Course I'), 'ilMailRoleAddressType', function() use ($that) {
93  $database = $that->getMockBuilder('ilDBInterface')->getMock();
94  $result = $that->getMockBuilder('ilDBStatement')->getMock();
95  $result->expects($that->any())->method('numRows')->will($that->returnValue(0));
96  $database->expects($that->any())->method('query')->will($that->returnValue($result));
97  $that->setGlobalVariable('ilDB', $database);
98  })
99  ];
100  }
$result
Create styles array
The data for the language used.
Class ilMailAddress.

◆ setGlobalVariable()

ilMailAddressTypesTest::setGlobalVariable (   $name,
  $value 
)
protected
Parameters
string$name
mixed$value

Definition at line 24 of file ilMailAddressTypesTest.php.

References $DIC, and $GLOBALS.

Referenced by setUp().

25  {
26  global $DIC;
27 
28  $GLOBALS[$name] = $value;
29 
30  unset($DIC[$name]);
31  $DIC[$name] = function ($c) use ($name) {
32  return $GLOBALS[$name];
33  };
34  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $DIC
+ Here is the caller graph for this function:

◆ setUp()

ilMailAddressTypesTest::setUp ( )

Definition at line 39 of file ilMailAddressTypesTest.php.

References array, and setGlobalVariable().

40  {
41  $this->setGlobalVariable('ilDB', $this->getMockBuilder('ilDBInterface')->getMock());
42 
43  $user = $this->getMockBuilder('ilObjUser')->disableOriginalConstructor()->setMethods(array('getId'))->getMock();
44  $user->expects($this->any())->method('getId')->will($this->returnValue(6));
45  $this->setGlobalVariable('ilUser', $user);
46 
47  parent::setUp();
48  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ testFactoryShouldReturnShouldReturnProperAddressType()

ilMailAddressTypesTest::testFactoryShouldReturnShouldReturnProperAddressType ( ilMailAddress  $address,
  $expectedAddressType,
callable  $preRunCallback = null 
)

addressTypes

Parameters
ilMailAddress$address
string$expectedAddressType
callable$preRunCallback

Definition at line 56 of file ilMailAddressTypesTest.php.

References ilMailAddressTypeFactory\getByPrefix().

57  {
58  if(is_callable($preRunCallback))
59  {
60  $preRunCallback();
61  }
62 
63  $this->assertInstanceOf($expectedAddressType, ilMailAddressTypeFactory::getByPrefix($address));
64  }
static getByPrefix(ilMailAddress $a_address)
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: