File tree 5 files changed +94
-0
lines changed
5 files changed +94
-0
lines changed Original file line number Diff line number Diff line change
1
+ composer.phar
2
+ /vendor /
3
+ composer.lock
Original file line number Diff line number Diff line change 18
18
"require" : {
19
19
"simplesamlphp/simplesamlphp" : " ~1.0" ,
20
20
"simplesamlphp/composer-module-installer" : " ~1.0"
21
+ },
22
+ "require-dev" : {
23
+ "phpunit/phpunit" : " ^6"
24
+ },
25
+ "autoload-dev" : {
26
+ "classmap" : [" lib/" , " tests/lib/" ]
21
27
}
22
28
}
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <phpunit
3
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi : noNamespaceSchemaLocation =" https://schema.phpunit.de/6.3/phpunit.xsd"
5
+ >
6
+ <testsuites >
7
+ <testsuite name =" drupalauth" >
8
+ <directory suffix =" Test.php" >tests/</directory >
9
+ </testsuite >
10
+
11
+ </testsuites >
12
+
13
+ </phpunit >
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: kirill
5
+ * Date: 6/09/18
6
+ * Time: 4:07 PM
7
+ */
8
+
9
+ class Property
10
+ {
11
+ protected $ name ;
12
+ protected $ value ;
13
+
14
+ /**
15
+ * Property constructor.
16
+ */
17
+ public function __construct ($ name )
18
+ {
19
+ $ this ->name = $ name ;
20
+ }
21
+
22
+ public function set ($ value )
23
+ {
24
+ $ this ->value = $ value ;
25
+ }
26
+
27
+
28
+ public function __get ($ name )
29
+ {
30
+ if ($ this ->name !== $ name ) {
31
+ throw new \Exception ('Property name mismatch. ' );
32
+ }
33
+
34
+ return $ this ->value ;
35
+ }
36
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: kirill
5
+ * Date: 6/09/18
6
+ * Time: 4:09 PM
7
+ */
8
+
9
+ use PHPUnit \Framework \TestCase ;
10
+
11
+ class PropertyTest extends TestCase
12
+ {
13
+
14
+ public function testSet ()
15
+ {
16
+ $ property = new Property ('test ' );
17
+ $ property ->set ('value ' );
18
+ $ this ->assertEquals ('value ' , $ property ->test );
19
+ }
20
+
21
+ /**
22
+ * @expectedException \Exception
23
+ * @expectedExceptionMessage Property name mismatch.
24
+ */
25
+ public function testBadName ()
26
+ {
27
+ $ property = new Property ('test ' );
28
+ $ test = $ property ->bad_name ;
29
+ }
30
+
31
+ public function testName ()
32
+ {
33
+ $ property = new Property ('test ' );
34
+ $ this ->assertEquals (null , $ property ->test , 'Return value for proper name ' );
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments