
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <description></description>
    <link>http://magnetik.org</link>
    <atom:link href="http://magnetik.orghttp://magnetik.org/feed.xml" rel="self" type="application/rss+xml" />
    
      <item>
        <title>Use decorator to mock redis connection in Symfony</title>
        <description>&lt;p&gt;To use redis conveniently in my Symfony projects, I use &lt;a href=&quot;https://github.com/snc/SncRedisBundle&quot;&gt;Snc Redis Bundle&lt;/a&gt; that automagically defines the service &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;snc_redis.default_client&lt;/code&gt; which is injected as arguments in other service.
But here comes the functional tests, and the redis server is not up, or not in a “clean” state.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/M6Web/RedisMock&quot;&gt;RedisMock&lt;/a&gt; from M6Web can helps by mocking the redis functions but I needed to replace the snc bundle services in the test env only.&lt;/p&gt;

&lt;p&gt;I’ve found decorating the snc service in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;services_test.xml&lt;/code&gt; convenient:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &amp;lt;service
        id=&quot;snc_redis.default_client.mock&quot;
        class=&quot;M6Web\Component\RedisMock\RedisMock&quot;
        decorates=&quot;snc_redis.default_client&quot;
    &amp;gt;
        &amp;lt;factory service=&quot;M6Web\Component\RedisMock\RedisMockFactory&quot; method=&quot;getAdapter&quot;/&amp;gt;
        &amp;lt;argument&amp;gt;Predis\Client&amp;lt;/argument&amp;gt;

    &amp;lt;/service&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;What do you think?&lt;/p&gt;
</description>
        <pubDate>Wed, 29 Aug 2018 00:00:00 +0000</pubDate>
        <link>http://magnetik.org/2018/redis-mock/</link>
        <guid isPermaLink="true">http://magnetik.org/2018/redis-mock/</guid>
      </item>
    
      <item>
        <title>My first post</title>
        <description>&lt;p&gt;I have had had a blog for quite a long time but most of the content was really old (4 years is like ancient internet old).&lt;/p&gt;
</description>
        <pubDate>Fri, 30 Dec 2016 00:00:00 +0000</pubDate>
        <link>http://magnetik.org/2016/first/</link>
        <guid isPermaLink="true">http://magnetik.org/2016/first/</guid>
      </item>
    
  </channel>
</rss>
