Skip to content

Commit 0a49a25

Browse files
authored
Merge pull request #1096 from hydephp/update-tests
Internal: Update tests
2 parents 2d6e9be + 21560b4 commit 0a49a25

File tree

12 files changed

+244
-194
lines changed

12 files changed

+244
-194
lines changed

packages/framework/tests/Feature/Commands/DebugCommandTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
*/
1212
class DebugCommandTest extends TestCase
1313
{
14+
protected function setUp(): void
15+
{
16+
parent::setUp();
17+
18+
$this->app->bind('git.version', fn () => 'foo');
19+
}
20+
1421
public function test_debug_command_can_run()
1522
{
1623
$this->artisan('debug')->assertExitCode(0);

packages/framework/tests/Feature/Commands/PackageDiscoverCommandTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@
1313
*/
1414
class PackageDiscoverCommandTest extends TestCase
1515
{
16-
public function test_package_discover_command_can_run()
17-
{
18-
$this->artisan('package:discover')->assertExitCode(0);
19-
}
20-
2116
public function test_package_discover_command_registers_manifest_path()
2217
{
2318
$this->artisan('package:discover')->assertExitCode(0);
19+
2420
$this->assertEquals(Hyde::path('app/storage/framework/cache/packages.php'),
25-
$this->app->make(PackageManifest::class)->manifestPath);
21+
$this->app->make(PackageManifest::class)->manifestPath
22+
);
23+
2624
$this->assertFileExists(Hyde::path('app/storage/framework/cache/packages.php'));
2725
}
2826
}

packages/framework/tests/Feature/Commands/PublishViewsCommandTest.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ class PublishViewsCommandTest extends TestCase
1717
public function test_command_publishes_views()
1818
{
1919
$path = str_replace('\\', '/', Hyde::pathToRelative(realpath(Hyde::vendorPath('resources/views/pages/404.blade.php'))));
20-
$this->artisan('publish:views all')
20+
$this->artisan('publish:views')
21+
->expectsQuestion('Which category do you want to publish?', 'all')
2122
->expectsOutputToContain("Copying file [$path] to [_pages/404.blade.php]")
2223
->assertExitCode(0);
2324

@@ -28,17 +29,6 @@ public function test_command_publishes_views()
2829
}
2930
}
3031

31-
public function test_command_prompts_for_input()
32-
{
33-
$this->artisan('publish:views')
34-
->expectsQuestion('Which category do you want to publish?', 'all')
35-
->assertExitCode(0);
36-
37-
if (is_dir(Hyde::path('resources/views/vendor/hyde'))) {
38-
File::deleteDirectory(Hyde::path('resources/views/vendor/hyde'));
39-
}
40-
}
41-
4232
public function test_can_select_view()
4333
{
4434
$path = str_replace('\\', '/', Hyde::pathToRelative(realpath(Hyde::vendorPath('resources/views/pages/404.blade.php'))));

packages/framework/tests/Feature/FeaturedImageTest.php

Lines changed: 2 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Hyde\Framework\Testing\Feature;
66

7-
use Hyde\Framework\Exceptions\FileNotFoundException;
87
use Hyde\Framework\Factories\FeaturedImageFactory;
98
use Hyde\Framework\Features\Blogging\Models\FeaturedImage;
109
use Hyde\Markdown\Models\FrontMatter;
@@ -13,104 +12,11 @@
1312

1413
/**
1514
* @covers \Hyde\Framework\Features\Blogging\Models\FeaturedImage
15+
*
16+
* @see \Hyde\Framework\Testing\Unit\FeaturedImageUnitTest
1617
*/
1718
class 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

255125
class 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

268133
class 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

281141
class 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

Comments
 (0)