File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
Integration/Porter/Connector Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 1515use ScriptFUSIONTest \FixtureFactory ;
1616use ScriptFUSIONTest \Stubs \TestOptions ;
1717
18+ /**
19+ * @see CachingConnector
20+ */
1821final class CachingConnectorTest extends \PHPUnit_Framework_TestCase
1922{
2023 use MockeryPHPUnitIntegration;
@@ -193,6 +196,24 @@ public function testFetchThrowsInvalidCacheKeyExceptionOnNonPSR6CompliantCacheKe
193196 $ connector ->fetch ($ this ->context , 'baz ' );
194197 }
195198
199+ /**
200+ * Tests that getting the wrapped connector returns exactly the same connector as constructed with.
201+ */
202+ public function testGetWrappedConnector ()
203+ {
204+ self ::assertSame ($ this ->wrappedConnector , $ this ->connector ->getWrappedConnector ());
205+ }
206+
207+ /**
208+ * Tests that cloning the caching connector also clones the wrapped connector.
209+ */
210+ public function testClone ()
211+ {
212+ $ clone = clone $ this ->connector ;
213+
214+ self ::assertNotSame ($ this ->wrappedConnector , $ clone ->getWrappedConnector ());
215+ }
216+
196217 private function createConnector (MockInterface $ cache = null , MockInterface $ cacheKeyGenerator = null )
197218 {
198219 return new CachingConnector ($ this ->wrappedConnector , $ cache , $ cacheKeyGenerator );
Original file line number Diff line number Diff line change 44use ScriptFUSION \Porter \Cache \CacheUnavailableException ;
55use ScriptFUSION \Porter \Connector \CachingConnector ;
66use ScriptFUSION \Porter \Connector \Connector ;
7+ use ScriptFUSION \Porter \Connector \ConnectorWrapper ;
78use ScriptFUSION \Porter \Connector \FetchExceptionHandler \FetchExceptionHandler ;
89use ScriptFUSION \Porter \Connector \ImportConnector ;
910use ScriptFUSIONTest \FixtureFactory ;
@@ -107,4 +108,20 @@ public function testSetExceptionHandlerTwice()
107108 $ this ->setExpectedException (\LogicException::class);
108109 $ connector ->setExceptionHandler ($ handler );
109110 }
111+
112+ /**
113+ * Tests that finding the base connector returns the connector at the bottom of a ConnectorWrapper stack.
114+ */
115+ public function testFindBaseConnector ()
116+ {
117+ $ connector = new ImportConnector (
118+ \Mockery::mock (Connector::class, ConnectorWrapper::class)
119+ ->shouldReceive ('getWrappedConnector ' )
120+ ->andReturn ($ baseConnector = \Mockery::mock (Connector::class))
121+ ->getMock (),
122+ FixtureFactory::buildConnectionContext ()
123+ );
124+
125+ self ::assertSame ($ baseConnector , $ connector ->findBaseConnector ());
126+ }
110127}
You can’t perform that action at this time.
0 commit comments