Skip to content

Commit

Permalink
ci
Browse files Browse the repository at this point in the history
  • Loading branch information
JirsaR committed Jan 13, 2020
1 parent 911f209 commit 0414e48
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
44 changes: 44 additions & 0 deletions tests/Unit/Transport/Udp/UdpSender2Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php declare(strict_types=1);

namespace CommonsBundleTests\Unit\Transport\Udp;

use CommonsBundleTests\KernelTestCaseAbstract;
use Exception;
use Hanaboso\CommonsBundle\Transport\Udp\UDPSender;
use Hanaboso\PhpCheckUtils\PhpUnit\Traits\PrivateTrait;
use phpmock\phpunit\PHPMock;

/**
* Class UdpSender2Test
*
* @package CommonsBundleTests\Unit\Transport\Udp
*/
final class UdpSender2Test extends KernelTestCaseAbstract
{

use PHPMock;
use PrivateTrait;

/**
* @covers \Hanaboso\CommonsBundle\Transport\Udp\UDPSender::send
*
* @throws Exception
*/
public function testSendErr(): void
{
$message = 'abc,name=def,host=ghi key1=val1,key2=val2 1465839830100400200';

$this->getFunctionMock('Hanaboso\CommonsBundle\Transport\Udp', 'socket_last_error')
->expects(self::any())
->willReturn(5);

$this->getFunctionMock('Hanaboso\CommonsBundle\Transport\Udp', 'socket_sendto')
->expects(self::any())
->willReturn(FALSE);

$sender = new UDPSender();
$result = $sender->send('influxdb:61999', $message);
self::assertFalse($result);
}

}
8 changes: 1 addition & 7 deletions tests/Unit/Transport/Udp/UdpSenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ final class UdpSenderTest extends KernelTestCaseAbstract

/**
* @covers \Hanaboso\CommonsBundle\Transport\Udp\UDPSender::getSocket
* @covers \Hanaboso\CommonsBundle\Transport\Udp\UDPSender::send
*
* @throws Exception
*/
Expand All @@ -41,14 +40,9 @@ public function testGetSocket(): void

$sender = new UDPSender();
$this->setProperty($sender, 'socket', '1');

$this->invokeMethod($sender, 'getSocket');
self::assertTrue(TRUE);

$message = 'abc,name=def,host=ghi key1=val1,key2=val2 1465839830100400200';
$sender = new UDPSender();
$result = $sender->send('influxdb:61999', $message);
self::assertFalse($result);
self::assertTrue(TRUE);
}

}

0 comments on commit 0414e48

Please sign in to comment.