@@ -39,20 +39,20 @@ public function testGetBufferEmptyNull()
3939
4040 public function testWriteBytes ()
4141 {
42- $ bytes = '41424344 ' ;
42+ $ bytes = Buffer::hex ('41424344 ' );
43+
4344 $ parser = new Parser ();
44- $ parser ->writeBytes (4 , Buffer::hex ($ bytes ));
45- $ returned = $ parser ->getBuffer ()->getHex ();
46- $ this ->assertSame ($ returned , '41424344 ' );
45+ $ parser ->writeBytes (4 , $ bytes );
46+ $ this ->assertTrue ($ parser ->getBuffer ()->equals ($ bytes ));
4747 }
4848
4949 public function testWriteBytesFlip ()
5050 {
51- $ bytes = '41424344 ' ;
51+ $ bytes = Buffer:: hex ( '41424344 ' ) ;
5252 $ parser = new Parser ();
53- $ parser ->writeBytes (4 , Buffer:: hex ( $ bytes) , true );
54- $ returned = $ parser -> getBuffer ()-> getHex ();
55- $ this ->assertSame ( $ returned , '44434241 ' );
53+ $ parser ->writeBytes (4 , $ bytes , true );
54+
55+ $ this ->assertEquals ( '44434241 ' , $ parser -> getBuffer ()-> getHex () );
5656 }
5757
5858 public function testWriteBytesPadded ()
@@ -71,26 +71,24 @@ public function testWriteBytesFlipPadded()
7171
7272 public function testReadBytes ()
7373 {
74- $ bytes = '41424344 ' ;
74+ $ bytes = Buffer:: hex ( '41424344 ' ) ;
7575
7676 $ parser = new Parser ($ bytes );
7777 $ read = $ parser ->readBytes (4 );
7878 $ this ->assertInstanceOf (Buffer::class, $ read );
7979
80- $ hex = $ read ->getHex ();
81- $ this ->assertSame ($ bytes , $ hex );
80+ $ this ->assertTrue ($ read ->equals ($ bytes ));
8281 }
8382
8483 public function testReadBytesFlip ()
8584 {
86- $ bytes = '41424344 ' ;
85+ $ bytes = Buffer:: hex ( '41424344 ' ) ;
8786
8887 $ parser = new Parser ($ bytes );
8988 $ read = $ parser ->readBytes (4 , true );
9089 $ this ->assertInstanceOf (Buffer::class, $ read );
9190
92- $ hex = $ read ->getHex ();
93- $ this ->assertSame ('44434241 ' , $ hex );
91+ $ this ->assertEquals ($ bytes ->flip ()->getHex (), $ read ->getHex ());
9492 }
9593
9694 /**
@@ -103,16 +101,15 @@ public function testReadBytesEmpty()
103101 // and length is zero.
104102
105103 $ parser = new Parser ();
106- $ data = $ parser ->readBytes (0 );
107- $ this ->assertFalse (!!$ data );
104+ $ parser ->readBytes (0 );
108105 }
109106 /**
110107 * @expectedException \BitWasp\Buffertools\Exceptions\ParserOutOfRange
111108 * @expectedExceptionMessage Could not parse string of required length (empty)
112109 */
113110 public function testReadBytesEndOfString ()
114111 {
115- $ parser = new Parser ('4041414142414141 ' );
112+ $ parser = new Parser (Buffer:: hex ( '4041414142414141 ' ) );
116113 $ bytes1 = $ parser ->readBytes (4 );
117114 $ bytes2 = $ parser ->readBytes (4 );
118115 $ this ->assertSame ($ bytes1 ->getHex (), '40414141 ' );
@@ -125,7 +122,7 @@ public function testReadBytesEndOfString()
125122 */
126123 public function testReadBytesBeyondLength ()
127124 {
128- $ bytes = '41424344 ' ;
125+ $ bytes = Buffer:: hex ( '41424344 ' ) ;
129126 $ parser = new Parser ($ bytes );
130127 $ parser ->readBytes (5 );
131128 }
0 commit comments