From 8747c4ff2c52f1a78a4b2aaae765cc961d9c9430 Mon Sep 17 00:00:00 2001 From: Adam Wathan Date: Mon, 9 Jul 2018 10:08:00 -0400 Subject: [PATCH] Make icons inline by default without a config file --- src/SvgFactory.php | 2 +- tests/SvgFactoryTest.php | 38 +++++++++++++++++++------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/SvgFactory.php b/src/SvgFactory.php index 207d61c..72c4da7 100644 --- a/src/SvgFactory.php +++ b/src/SvgFactory.php @@ -13,7 +13,7 @@ class SvgFactory private $files; private $svgCache; private $config = [ - 'inline' => false, + 'inline' => true, 'class' => 'icon', 'sprite_prefix' => '', ]; diff --git a/tests/SvgFactoryTest.php b/tests/SvgFactoryTest.php index a891903..6550188 100644 --- a/tests/SvgFactoryTest.php +++ b/tests/SvgFactoryTest.php @@ -16,20 +16,20 @@ public function can_render_spritesheet() } /** @test */ - public function icons_are_rendered_from_spritesheet_by_default() + public function icons_are_rendered_inline_by_default() { - $factory = new SvgFactory(['class' => 'icon']); + $factory = new SvgFactory(['class' => 'icon', 'svg_path' => __DIR__.'/resources/icons/']); $result = $factory->svg('arrow-thick-up')->toHtml(); - $expected = ''; + $expected = ''; $this->assertEquals($expected, $result); } /** @test */ public function icons_are_given_the_icon_class_by_default() { - $factory = new SvgFactory(); + $factory = new SvgFactory(['svg_path' => __DIR__.'/resources/icons/']); $result = $factory->svg('arrow-thick-up')->toHtml(); - $expected = ''; + $expected = ''; $this->assertEquals($expected, $result); } @@ -54,63 +54,63 @@ public function can_render_inline_icon() /** @test */ public function can_render_icon_with_additional_classes() { - $factory = new SvgFactory(); + $factory = new SvgFactory(['svg_path' => __DIR__.'/resources/icons/']); $result = $factory->svg('arrow-thick-up', 'icon-lg inline-block')->toHtml(); - $expected = ''; + $expected = ''; $this->assertEquals($expected, $result); } /** @test */ public function can_specify_additional_attributes_as_an_array() { - $factory = new SvgFactory(); + $factory = new SvgFactory(['svg_path' => __DIR__.'/resources/icons/']); $result = $factory->svg('arrow-thick-up', 'icon-lg', ['alt' => 'Alt text', 'id' => 'arrow-icon'])->toHtml(); - $expected = ''; + $expected = ''; $this->assertEquals($expected, $result); } /** @test */ public function can_skip_class_parameter() { - $factory = new SvgFactory(); + $factory = new SvgFactory(['svg_path' => __DIR__.'/resources/icons/']); $result = $factory->svg('arrow-thick-up', ['alt' => 'Alt text', 'id' => 'arrow-icon'])->toHtml(); - $expected = ''; + $expected = ''; $this->assertEquals($expected, $result); } /** @test */ public function attributes_without_keys_are_used_as_valueless_html_attributes() { - $factory = new SvgFactory(); + $factory = new SvgFactory(['svg_path' => __DIR__.'/resources/icons/']); $result = $factory->svg('arrow-thick-up', ['alt' => 'Alt text', 'data-foo'])->toHtml(); - $expected = ''; + $expected = ''; $this->assertEquals($expected, $result); } /** @test */ public function specifying_class_as_attribute_overrides_default_class() { - $factory = new SvgFactory(['class' => 'default']); + $factory = new SvgFactory(['class' => 'default', 'svg_path' => __DIR__.'/resources/icons/']); $result = $factory->svg('arrow-thick-up', ['class' => 'overridden'])->toHtml(); - $expected = ''; + $expected = ''; $this->assertEquals($expected, $result); } /** @test */ public function can_chain_additional_attributes() { - $factory = new SvgFactory(); + $factory = new SvgFactory(['svg_path' => __DIR__.'/resources/icons/']); $result = $factory->svg('arrow-thick-up')->alt('Alt text')->id('arrow-icon')->toHtml(); - $expected = ''; + $expected = ''; $this->assertEquals($expected, $result); } /** @test */ public function camelcase_attributes_are_dash_cased_when_chaining() { - $factory = new SvgFactory(); + $factory = new SvgFactory(['svg_path' => __DIR__.'/resources/icons/']); $result = $factory->svg('arrow-thick-up')->dataFoo('bar')->toHtml(); - $expected = ''; + $expected = ''; $this->assertEquals($expected, $result); }