/**
  * Test instance with Monolog passed.
  *
  * @throws \WebservicesNl\Common\Exception\Client\InputException
  * @throws \InvalidArgumentException
  * @throws \WebservicesNl\Common\Exception\Server\NoServerAvailableException
  */
 public function testInstanceWithLogger()
 {
     $handler = new TestHandler();
     $logger = new Logger('unit-test', [$handler]);
     $config = new PlatformConfig();
     $factory = SoapFactory::build($config);
     $factory->setLogger($logger);
     $soapClient = $factory->create(['username' => 'johndoe', 'password' => 'fakePassword']);
     static::assertAttributeInstanceOf('\\Psr\\Log\\LoggerInterface', 'logger', $factory);
     static::assertTrue($factory->hasLogger());
     static::assertAttributeInstanceOf('\\Psr\\Log\\LoggerInterface', 'logger', $soapClient);
     static::assertTrue($handler->hasInfoThatContains('Created SoapClient for Webservices'));
     static::assertTrue($handler->hasDebugThatContains('Created SoapClient'));
     static::assertInstanceOf('WebservicesNl\\Protocol\\Soap\\Config\\Platform\\Webservices\\Converter', $soapClient->getConverter());
 }
Exemplo n.º 2
0
 /**
  * Test the parseOrigin with values
  * Uses reflection as this is a protected method.
  *
  * @test
  * @covers \Bairwell\MiddlewareCors\Traits\Parse::parseOrigin
  */
 public function testParseOriginInvalidString()
 {
     $sut = new MiddlewareCors();
     // setup the logger
     $this->logger = new Logger('test');
     $this->testLogger = new TestHandler();
     $this->logger->pushHandler($this->testLogger);
     $sut->setLogger($this->logger);
     //
     $reflection = new \ReflectionClass(get_class($sut));
     $settingsProperty = $reflection->getProperty('settings');
     $settingsProperty->setAccessible(true);
     $method = $reflection->getMethod('parseOrigin');
     $method->setAccessible(true);
     $request = $this->getMockBuilder('Psr\\Http\\Message\\ServerRequestInterface')->disableOriginalConstructor()->getMock();
     $request->expects($this->once())->method('getHeaderLine')->with('origin')->willReturn(123);
     $result = $method->invokeArgs($sut, [$request]);
     $this->assertSame('', $result);
     // check the logger
     $this->assertTrue($this->testLogger->hasDebugThatContains('Origin is empty or is not a string'));
 }