1+ <?php
2+ namespace umanskyi31 \opengraph \test \Unit \src \Tags ;
3+
4+ use PHPUnit \Framework \TestCase ;
5+ use umanskyi31 \opengraph \OpenGraph ;
6+ use umanskyi31 \opengraph \Tags \Audio ;
7+
8+ class AudioTest extends TestCase
9+ {
10+ /**
11+ * @var OpenGraph
12+ */
13+ protected $ opengraph ;
14+
15+ protected function setUp ()
16+ {
17+ parent ::setUp ();
18+
19+ $ this ->opengraph = new OpenGraph ();
20+ }
21+
22+ public function testSetUrl ()
23+ {
24+ $ audio = new Audio ($ this ->opengraph );
25+
26+ $ url = 'https://umanskyi.com/test.mp3 ' ;
27+
28+ $ audio ->setUrl ($ url );
29+
30+ $ this ->assertSame ($ url , $ audio ->getUrl ());
31+
32+ }
33+
34+ public function testSetAttribute ()
35+ {
36+ $ audio = new Audio ($ this ->opengraph );
37+
38+ $ attr = [
39+ 'type ' => 'test ' ,
40+ 'secure_url ' => 'https://umanskyi.com/test.mp3 '
41+ ];
42+
43+ $ audio ->setAttributes ($ attr );
44+
45+ $ this ->assertEquals ($ attr , $ audio ->getAttributes ());
46+ }
47+
48+ /**
49+ * @expectedException \Exception
50+ * @expectedExceptionMessage Invalid values
51+ * @expectedExceptionCode 500
52+ */
53+ public function testSetAttributeFailure ()
54+ {
55+ $ audio = new Audio ($ this ->opengraph );
56+
57+ $ attr = [
58+ 'type ' => 'test ' ,
59+ 'secure_url ' => 'https://umanskyi.com/test.mp3 ' ,
60+ 'not_valid_url ' => 'test '
61+ ];
62+
63+ $ audio ->setAttributes ($ attr );
64+
65+ $ this ->assertEquals ($ attr , $ audio ->getAttributes ());
66+ }
67+
68+ }
0 commit comments