File tree Expand file tree Collapse file tree 6 files changed +57
-2
lines changed Expand file tree Collapse file tree 6 files changed +57
-2
lines changed Original file line number Diff line number Diff line change 1
1
/vendor /
2
+ composer.lock.json
Original file line number Diff line number Diff line change 14
14
"WebSocket\\ " : " src/"
15
15
}
16
16
},
17
- "require" : {}
17
+ "require" : {
18
+ "phpunit/phpunit" : " ^9.3"
19
+ }
18
20
}
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 2
2
3
3
namespace WebSocket ;
4
4
5
+ use Websocket \Credential \ICredential ;
6
+
5
7
class Socket
6
8
{
7
9
protected ?ICredential $ credential ;
8
10
9
11
/**
10
12
* DI of SocketCredentials
11
- * @param ICredential $credential
13
+ * @param \Websocket\Credential\ ICredential $credential
12
14
* @return void
13
15
*/
14
16
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