-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
703d5bc
commit 1bc0582
Showing
11 changed files
with
145 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace PhpDesignPrinciples\Tests\Unit\Patterns\Service\Strategy\HttpClientAssetServiceClientTest; | ||
|
||
use PhpDesignPrinciples\Patterns\Service\Strategy\HttpClientAssetServiceClient; | ||
use PhpDesignPrinciples\Patterns\Service\Config\WebServiceConfig; | ||
use PhpDesignPrinciples\Patterns\Service\Proxy\CachingProxy; | ||
use PhpDesignPrinciples\Patterns\Service\Proxy\ProfilingProxy; | ||
use PhpDesignPrinciples\Patterns\Http\Strategy\PeclHttpUrlLoader; | ||
use Doctrine\Common\Cache\ApcCache; | ||
use PhpDesignPrinciples\Patterns\Cache\Adapter\DoctrineCacheAdapter; | ||
use PhpDesignPrinciples\Patterns\Cache\Strategy\SimpleArrayCache; | ||
use PhpDesignPrinciples\Patterns\Cache\Strategy\FakeCache; | ||
|
||
|
||
/** | ||
* This is not an actual test it just shows how we can assemble alternative configurations | ||
* of objects | ||
*/ | ||
class CodeExamplesTest extends \PHPUnit_Framework_TestCase { | ||
|
||
public function testMinimalAssembly() { | ||
$config = new WebServiceConfig(); | ||
$httpClient = new PeclHttpUrlLoader(); | ||
$rawService = new HttpClientAssetServiceClient($httpClient, $config); | ||
|
||
// these will be different as we call the service twice | ||
$rawService->getAsset(34)->getInstanceUid(); | ||
$rawService->getAsset(34)->getInstanceUid(); | ||
} | ||
|
||
public function testFullAssembly() { | ||
$this->markTestSkipped(); | ||
$config = new WebServiceConfig(); | ||
$cache = new SimpleArrayCache(); | ||
$rawService = new HttpClientAssetServiceClient(new PeclHttpUrlLoader(), $config); | ||
$profiledService = new ProfilingProxy($rawService); | ||
$cachedProfiledService = new CachingProxy($profiledService, $cache); | ||
|
||
// these will be the same as the second call is cached | ||
$cachedProfiledService->getAsset(34)->getInstanceUid(); | ||
$cachedProfiledService->getAsset(34)->getInstanceUid(); | ||
} | ||
|
||
public function testFullAssemblyDoctrine() { | ||
$this->markTestSkipped(); | ||
$config = new WebServiceConfig(); | ||
$cache = new DoctrineCacheAdapter(new ApcCache()); | ||
$rawService = new HttpClientAssetServiceClient(new PeclHttpUrlLoader(), $config); | ||
$profiledService = new ProfilingProxy($rawService); | ||
$cachedProfiledService = new CachingProxy($profiledService, $cache); | ||
|
||
// these will be the same as the second call is cached | ||
$cachedProfiledService->getAsset(34)->getInstanceUid(); | ||
$cachedProfiledService->getAsset(34)->getInstanceUid(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace PhpDesignPrinciples\Tests\Unit\Patterns\Service\Strategy\HttpClientAssetServiceClientTest; | ||
|
||
use PhpDesignPrinciples\Patterns\Service\Strategy\HttpClientAssetServiceClient; | ||
use PhpDesignPrinciples\Patterns\Service\Config\WebServiceConfig; | ||
|
||
class CachingProxyTest extends \PHPUnit_Framework_TestCase { | ||
|
||
public function setup() { | ||
parent::setup(); | ||
$this->httpClient = $this->getMock('PhpDesignPrinciples\Patterns\Http\SimpleHttpClientInterface', array(), array(), '', false); | ||
$this->config = new WebServiceConfig(); | ||
} | ||
|
||
public function testFetchValid() { | ||
$this->assertEquals(1,1); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters