-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
/** | ||
* async-sockets | ||
* | ||
* @copyright Copyright (c) 2015, Efimov Evgenij <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Tests\AsyncSockets\Frame; | ||
|
||
use AsyncSockets\Frame\FramePickerInterface; | ||
use AsyncSockets\Frame\RawFramePicker; | ||
|
||
/** | ||
* Class RawFramePickerTest | ||
*/ | ||
class RawFramePickerTest extends AbstractFramePickerTest | ||
{ | ||
/** {@inheritdoc} */ | ||
protected function createFramePicker() | ||
{ | ||
return new RawFramePicker(); | ||
} | ||
|
||
/** | ||
* testReadSingleFrame | ||
* | ||
* @return void | ||
*/ | ||
public function testReadSingleFrame() | ||
{ | ||
$data = md5(microtime(true)); | ||
$picker = $this->createFramePicker(); | ||
$result = $picker->pickUpData($data); | ||
|
||
self::assertEmpty($result, 'Raw frame picker must always collect data on first call'); | ||
self::assertEquals($data, (string) $picker->createFrame(), 'Incorrect frame data'); | ||
self::assertTrue($picker->isEof(), 'EOF flag is not set'); | ||
} | ||
|
||
/** | ||
* testCantReadSecondTime | ||
* | ||
* @return void | ||
*/ | ||
public function testCantReadSecondTime() | ||
{ | ||
$data = md5(microtime(true)); | ||
$picker = $this->createFramePicker(); | ||
$picker->pickUpData($data); | ||
|
||
$secondData = sha1(microtime(true)); | ||
$result = $picker->pickUpData($secondData); | ||
self::assertEquals($secondData, $result, 'Raw frame picker must ignore data on second call'); | ||
self::assertEquals($data, (string) $picker->createFrame(), 'Incorrect frame data'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters