File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2323 "ramsey/uuid" : " ^3.4"
2424 },
2525 "require-dev" : {
26- "codeception/codeception" : " ~2.0"
26+ "mockery/mockery" : " 0.9.*" ,
27+ "phpunit/phpunit" : " ~4.0"
2728 },
2829 "authors" : [
2930 {
4041 "Nikapps\\ OrtcPhp\\ " : " src/"
4142 }
4243 },
44+ "autoload-dev" : {
45+ "psr-4" : {
46+ "Tests\\ " : " tests/"
47+ }
48+ },
4349 "minimum-stability" : " stable"
4450}
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <phpunit backupGlobals =" false"
3+ backupStaticAttributes =" false"
4+ bootstrap =" vendor/autoload.php"
5+ colors =" true"
6+ convertErrorsToExceptions =" true"
7+ convertNoticesToExceptions =" true"
8+ convertWarningsToExceptions =" true"
9+ processIsolation =" false"
10+ stopOnFailure =" false"
11+ syntaxCheck =" false"
12+ >
13+ <testsuites >
14+ <testsuite name =" Package Test Suite" >
15+ <directory suffix =" .php" >./tests/</directory >
16+ <exclude >./tests/TestCase.php</exclude >
17+ </testsuite >
18+ </testsuites >
19+ <filter >
20+ <whitelist >
21+ <directory suffix =" .php" >src</directory >
22+ </whitelist >
23+ </filter >
24+ </phpunit >
Original file line number Diff line number Diff line change 33
44class Channel
55{
6-
76 const PERMISSION_WRITE = 'w ' ;
87 const PERMISSION_READ = 'r ' ;
98
9+ /**
10+ * Construct
11+ *
12+ * @param string $name
13+ * @param string $permission
14+ */
15+ public function __construct ($ name = null , $ permission = self ::PERMISSION_READ )
16+ {
17+ $ this ->setName ($ name );
18+ $ this ->setPermission ($ permission );
19+ }
20+
1021 /**
1122 * name of channel
1223 *
@@ -58,4 +69,14 @@ public function setPermission($permission)
5869
5970 return $ this ;
6071 }
72+
73+ /**
74+ * To string returned name
75+ *
76+ * @return string
77+ */
78+ public function __toString ()
79+ {
80+ return $ this ->getName ();
81+ }
6182}
Original file line number Diff line number Diff line change 1+ <?php
2+ namespace Tests \Models ;
3+
4+ use Tests \TestCase ;
5+ use Nikapps \OrtcPhp \Models \Channel ;
6+
7+ class ChannelTest extends TestCase
8+ {
9+ public function testConstruct ()
10+ {
11+ $ channel1 = new Channel ('NAME1 ' );
12+ $ this ->assertEquals ('NAME1 ' , $ channel1 ->getName ());
13+ $ this ->assertEquals ('r ' , $ channel1 ->getPermission ());
14+
15+ $ channel2 = new Channel ('NAME_2 ' , Channel::PERMISSION_WRITE );
16+ $ this ->assertEquals ('NAME_2 ' , $ channel2 ->getName ());
17+ $ this ->assertEquals ('w ' , $ channel2 ->getPermission ());
18+ }
19+
20+ public function testSetAndGetAttributes ()
21+ {
22+ $ channel = new Channel ;
23+ $ this ->assertEquals ($ channel , $ channel ->setName ('channel_name ' ));
24+ $ this ->assertEquals ($ channel , $ channel ->setPermission (Channel::PERMISSION_READ ));
25+
26+ $ this ->assertEquals ('channel_name ' , $ channel ->getName ());
27+ $ this ->assertEquals ('r ' , $ channel ->getPermission ());
28+ }
29+
30+ public function testToString ()
31+ {
32+ $ channel = new Channel ('foobar ' );
33+ $ this ->assertEquals ('foobar ' , (string ) $ channel );
34+ }
35+ }
Original file line number Diff line number Diff line change 1+ <?php
2+ namespace Tests ;
3+
4+ use Mockery ;
5+
6+ class TestCase extends \PHPUnit_Framework_TestCase
7+ {
8+ public function tearDown ()
9+ {
10+ parent ::tearDown ();
11+ Mockery::close ();
12+ }
13+ }
You can’t perform that action at this time.
0 commit comments