44
55namespace Hyde \Framework \Testing \Feature ;
66
7- use Hyde \Framework \Exceptions \FileNotFoundException ;
87use Hyde \Framework \Factories \FeaturedImageFactory ;
98use Hyde \Framework \Features \Blogging \Models \FeaturedImage ;
109use Hyde \Markdown \Models \FrontMatter ;
1312
1413/**
1514 * @covers \Hyde\Framework\Features\Blogging\Models\FeaturedImage
15+ *
16+ * @see \Hyde\Framework\Testing\Unit\FeaturedImageUnitTest
1617 */
1718class FeaturedImageTest extends TestCase
1819{
19- public function testCanConstruct ()
20- {
21- $ this ->assertInstanceOf (FeaturedImage::class, new FeaturedImage ('foo ' ));
22- }
23-
24- public function testGetAltText ()
25- {
26- $ this ->assertNull ((new NullImage )->getAltText ());
27- $ this ->assertEquals ('alt ' , (new FilledImage )->getAltText ());
28- }
29-
30- public function testGetTitleText ()
31- {
32- $ this ->assertNull ((new NullImage )->getTitleText ());
33- $ this ->assertEquals ('title ' , (new FilledImage )->getTitleText ());
34- }
35-
36- public function testGetAuthorName ()
37- {
38- $ this ->assertNull ((new NullImage )->getAuthorName ());
39- $ this ->assertEquals ('author ' , (new FilledImage )->getAuthorName ());
40- }
41-
42- public function testGetAuthorUrl ()
43- {
44- $ this ->assertNull ((new NullImage )->getAuthorUrl ());
45- $ this ->assertEquals ('authorUrl ' , (new FilledImage )->getAuthorUrl ());
46- }
47-
48- public function testGetCopyrightText ()
49- {
50- $ this ->assertNull ((new NullImage )->getCopyrightText ());
51- $ this ->assertEquals ('copyright ' , (new FilledImage )->getCopyrightText ());
52- }
53-
54- public function testGetLicenseName ()
55- {
56- $ this ->assertNull ((new NullImage )->getLicenseName ());
57- $ this ->assertEquals ('license ' , (new FilledImage )->getLicenseName ());
58- }
59-
60- public function testGetLicenseUrl ()
61- {
62- $ this ->assertNull ((new NullImage )->getLicenseUrl ());
63- $ this ->assertEquals ('licenseUrl ' , (new FilledImage )->getLicenseUrl ());
64- }
65-
66- public function testHasAltText ()
67- {
68- $ this ->assertFalse ((new NullImage )->hasAltText ());
69- $ this ->assertTrue ((new FilledImage )->hasAltText ());
70- }
71-
72- public function testHasTitleText ()
73- {
74- $ this ->assertFalse ((new NullImage )->hasTitleText ());
75- $ this ->assertTrue ((new FilledImage )->hasTitleText ());
76- }
77-
78- public function testHasAuthorName ()
79- {
80- $ this ->assertFalse ((new NullImage )->hasAuthorName ());
81- $ this ->assertTrue ((new FilledImage )->hasAuthorName ());
82- }
83-
84- public function testHasAuthorUrl ()
85- {
86- $ this ->assertFalse ((new NullImage )->hasAuthorUrl ());
87- $ this ->assertTrue ((new FilledImage )->hasAuthorUrl ());
88- }
89-
90- public function testHasCopyrightText ()
91- {
92- $ this ->assertFalse ((new NullImage )->hasCopyrightText ());
93- $ this ->assertTrue ((new FilledImage )->hasCopyrightText ());
94- }
95-
96- public function testHasLicenseName ()
97- {
98- $ this ->assertFalse ((new NullImage )->hasLicenseName ());
99- $ this ->assertTrue ((new FilledImage )->hasLicenseName ());
100- }
101-
102- public function testHasLicenseUrl ()
103- {
104- $ this ->assertFalse ((new NullImage )->hasLicenseUrl ());
105- $ this ->assertTrue ((new FilledImage )->hasLicenseUrl ());
106- }
107-
108- public function testGetType ()
109- {
110- $ this ->assertEquals ('local ' , (new LocalImage )->getType ());
111- $ this ->assertEquals ('remote ' , (new RemoteImage )->getType ());
112- }
113-
11420 public function testGetMetadataArray ()
11521 {
11622 $ this ->assertSame ([
@@ -136,12 +42,6 @@ public function testGetMetadataArray()
13642 ], (new RemoteImage )->getMetadataArray ());
13743 }
13844
139- public function testGetContentLength ()
140- {
141- $ this ->assertEquals (0 , (new NullImage )->getContentLength ());
142- $ this ->assertEquals (0 , (new FilledImage )->getContentLength ());
143- }
144-
14545 public function testCanConstructFeaturedImage ()
14646 {
14747 $ image = new FeaturedImage ('_media/foo ' , ...$ this ->defaultArguments ());
@@ -158,31 +58,6 @@ public function testFeaturedImageGetContentLength()
15858 $ this ->assertEquals (5 , $ image ->getContentLength ());
15959 }
16060
161- public function testFeaturedImageGetContentLengthWithNoSource ()
162- {
163- $ this ->expectException (FileNotFoundException::class);
164- $ this ->expectExceptionMessage ('Image at _media/foo does not exist ' );
165-
166- $ image = new FeaturedImage ('_media/foo ' , ...$ this ->defaultArguments ());
167- $ this ->assertEquals (0 , $ image ->getContentLength ());
168- }
169-
170- public function testCanConstructFeaturedImageWithRemoteSource ()
171- {
172- $ image = new FeaturedImage ('http/foo ' , ...$ this ->defaultArguments ());
173- $ this ->assertInstanceOf (FeaturedImage::class, $ image );
174-
175- $ this ->assertEquals ('http/foo ' , $ image ->getSource ());
176- }
177-
178- public function testCanConstructFeaturedImageWithHttps ()
179- {
180- $ image = new FeaturedImage ('https/foo ' , ...$ this ->defaultArguments ());
181- $ this ->assertInstanceOf (FeaturedImage::class, $ image );
182-
183- $ this ->assertEquals ('https/foo ' , $ image ->getSource ());
184- }
185-
18661 public function testFeaturedImageGetContentLengthWithRemoteSource ()
18762 {
18863 Http::fake (function () {
@@ -245,11 +120,6 @@ public function __construct()
245120 {
246121 parent ::__construct ('source ' );
247122 }
248-
249- public function getContentLength (): int
250- {
251- return 0 ;
252- }
253123}
254124
255125class RemoteImage extends FeaturedImage
@@ -258,11 +128,6 @@ public function __construct()
258128 {
259129 parent ::__construct ('https://example.com ' );
260130 }
261-
262- public function getContentLength (): int
263- {
264- return 0 ;
265- }
266131}
267132
268133class NullImage extends FeaturedImage
@@ -271,11 +136,6 @@ public function __construct()
271136 {
272137 parent ::__construct ('source ' );
273138 }
274-
275- public function getContentLength (): int
276- {
277- return 0 ;
278- }
279139}
280140
281141class FilledImage extends FeaturedImage
@@ -284,9 +144,4 @@ public function __construct()
284144 {
285145 parent ::__construct ('source ' , 'alt ' , 'title ' , 'author ' , 'authorUrl ' , 'copyright ' , 'license ' , 'licenseUrl ' );
286146 }
287-
288- public function getContentLength (): int
289- {
290- return 0 ;
291- }
292147}
0 commit comments