File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11/vendor /
2+ composer.lock.json
Original file line number Diff line number Diff line change 1414 "WebSocket\\ " : " src/"
1515 }
1616 },
17- "require" : {}
17+ "require" : {
18+ "phpunit/phpunit" : " ^9.3"
19+ }
1820}
Original file line number Diff line number Diff line change 1+ <testsuites >
2+ <testsuite name =" Socket layer tests" >
3+ <directory >./tests/unit/*</directory >
4+ <file >./tests/unit/SocketTest.php</file >
5+ <file >./tests/unit/SocketCredentialsTest.php</file >
6+ </testsuite >
7+ </testsuites >
Original file line number Diff line number Diff line change 22
33namespace WebSocket ;
44
5+ use Websocket \Credential \ICredential ;
6+
57class Socket
68{
79 protected ?ICredential $ credential ;
810
911 /**
1012 * DI of SocketCredentials
11- * @param ICredential $credential
13+ * @param \Websocket\Credential\ ICredential $credential
1214 * @return void
1315 */
1416 public function setCredentials (ICredential $ credential )
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use PHPUnit \Framework \TestCase ;
4+ use WebSocket \Credential \SocketCredentials ;
5+
6+ class SocketCredentialsTest extends TestCase
7+ {
8+ public function testCredentialGetterReturnHost ()
9+ {
10+ $ credential = new SocketCredentials ();
11+
12+ $ this ->assertInstanceOf (
13+ \WebSocket \Credential \ICredential::class,
14+ $ credential
15+ );
16+
17+ $ credential ->setCredential ('host ' , 'localhost ' );
18+
19+ $ this ->assertSame (
20+ $ credential ->getCredential ('host ' ),
21+ 'localhost '
22+ );
23+ }
24+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use PHPUnit \Framework \TestCase ;
4+ use WebSocket \Credential \SocketCredentials ;
5+ use WebSocket \Socket ;
6+
7+ class SocketTest extends TestCase
8+ {
9+ public function testDIReturnSocketCredential ()
10+ {
11+ $ socket = new Socket ();
12+ $ socket ->setCredentials (new SocketCredentials ());
13+
14+ $ this ->assertInstanceOf (
15+ \WebSocket \Credential \SocketCredentials::class,
16+ $ socket ->getCredentials ()
17+ );
18+ }
19+ }
You can’t perform that action at this time.
0 commit comments