Compile Twig directly in tests

This commit is contained in:
Philipp Lang 2021-09-06 14:04:02 +02:00
parent 7d5f858ed7
commit ed17bd1945
1 changed files with 8 additions and 8 deletions

View File

@ -32,7 +32,7 @@ class ImageTagTest extends TestCase
$this->assertEquals(
'width="500" height="500" sizes="(max-width: 100px) 100px, (max-width: 200px) 200px, (max-width: 500px) 500px" srcset="/storage/uploads/public/c/pages/test-100x100.jpg 100w, /storage/uploads/public/c/pages/test-200x200.jpg 200w, /storage/uploads/public/c/pages/test-500x500.jpg 500w" src="/storage/uploads/public/c/pages/test-500x500.jpg"',
app(TagGenerator::class)->generate('pages/test.jpg'),
app(Twig::class)->parse('{{"pages/test.jpg" | resize}}'),
);
}
@ -46,7 +46,7 @@ class ImageTagTest extends TestCase
UploadedFile::fake()->image('test.jpg', 150, 100)->storeAs('uploads/public/c/pages', 'test-150x100.jpg', 'local');
$this->assertFalse(str_contains(
app(TagGenerator::class)->generate('pages/test.jpg'),
app(Twig::class)->parse('{{"pages/test.jpg" | resize}}'),
'150x100',
));
}
@ -64,11 +64,11 @@ class ImageTagTest extends TestCase
UploadedFile::fake()->image('test.jpg', 100, 200)->storeAs('uploads/public/c/pages', 'test-100x200.jpg', 'local');
$this->assertFalse(str_contains(
app(TagGenerator::class)->generate('pages/test.jpg', 'size'),
app(Twig::class)->parse('{{"pages/test.jpg" | resize("size")}}'),
'100x100',
));
$this->assertTrue(str_contains(
app(TagGenerator::class)->generate('pages/test.jpg', 'size'),
app(Twig::class)->parse('{{"pages/test.jpg" | resize("size")}}'),
'200x400',
));
}
@ -82,7 +82,7 @@ class ImageTagTest extends TestCase
UploadedFile::fake()->image('test.jpg', 640, 149)->storeAs('uploads/public/c/pages', 'test-640x149.jpg', 'local');
$this->assertTrue(str_contains(
app(TagGenerator::class)->generate('pages/test.jpg', 'size'),
app(Twig::class)->parse('{{"pages/test.jpg" | resize("size")}}'),
'640x149',
));
}
@ -107,15 +107,15 @@ class ImageTagTest extends TestCase
$this->media->put('/pages/test.svg', file_get_contents(__DIR__.'/stub/close.svg'));
$this->assertFalse(str_contains(
app(TagGenerator::class)->generate('pages/test.svg', 'size'),
app(Twig::class)->parse('{{"pages/test.svg" | resize}}'),
'srcset',
));
$this->assertFalse(str_contains(
app(TagGenerator::class)->generate('pages/test.svg', 'size'),
app(Twig::class)->parse('{{"pages/test.svg" | resize}}'),
'sizes',
));
$this->assertTrue(str_contains(
app(TagGenerator::class)->generate('pages/test.svg', 'size'),
app(Twig::class)->parse('{{"pages/test.svg" | resize}}'),
'src="'.$this->media->findFiles('/pages/test.svg')[0]->publicUrl.'"',
));
}