|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Test\Skautis; |
|
4
|
|
|
|
|
5
|
|
|
use Skautis\Config; |
|
6
|
|
|
use Skautis\Wsdl\WsdlManager; |
|
7
|
|
|
|
|
8
|
|
|
class WsdlManagerTest extends \PHPUnit_Framework_TestCase |
|
9
|
|
|
{ |
|
10
|
|
|
|
|
11
|
|
|
public function testGetSupportedWebServices() |
|
12
|
|
|
{ |
|
13
|
|
|
/** @var \Skautis\Wsdl\WebServiceFactory */ |
|
14
|
|
|
$factory = \Mockery::mock('\Skautis\Wsdl\WebServiceFactory'); |
|
15
|
|
|
/** @var \Skautis\Confi */ |
|
16
|
|
|
$config = \Mockery::mock('\Skautis\Config'); |
|
17
|
|
|
$manager = new WsdlManager($factory, $config); |
|
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
$services = $manager->getSupportedWebServices(); |
|
20
|
|
|
$this->assertInternalType('array', $services); |
|
21
|
|
|
$this->assertTrue(count($services) > 0); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
public function testGetWebService() |
|
25
|
|
|
{ |
|
26
|
|
|
$wsA = new \StdClass; |
|
27
|
|
|
$wsB = new \StdClass; |
|
28
|
|
|
|
|
29
|
|
|
$factory = \Mockery::mock('\Skautis\Wsdl\WebServiceFactory'); |
|
30
|
|
|
$factory->shouldReceive("createWebService")->withAnyArgs()->twice()->andReturn($wsA, $wsB); |
|
31
|
|
|
$config = new Config('42'); |
|
32
|
|
|
|
|
33
|
|
|
$manager = new WsdlManager($factory, $config); |
|
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
$config->setTestMode(true); |
|
36
|
|
|
$eventA = $manager->getWebService('UserManagement'); |
|
37
|
|
|
$this->assertSame($eventA, $manager->getWebService('UserManagement')); |
|
38
|
|
|
|
|
39
|
|
|
$config->setTestMode(false); |
|
40
|
|
|
$eventB = $manager->getWebService('UserManagement'); |
|
41
|
|
|
$this->assertNotSame($eventA, $eventB); |
|
42
|
|
|
|
|
43
|
|
|
$config->setTestMode(true); |
|
44
|
|
|
$this->assertSame($eventA, $manager->getWebService('UserManagement')); |
|
45
|
|
|
|
|
46
|
|
|
$this->assertSame($wsA, $eventA); |
|
47
|
|
|
$this->assertSame($wsB, $eventB); |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: