/** * @param StoreEntity $store * @return Client */ public function createClient(StoreEntity $store) { $client = new Client(array("shopUrl" => $store->getShopifyStoreUrl(), "X-Shopify-Access-Token" => $store->getShopifyAccessToken())); $loggerName = sprintf('shopify_%s', str_replace(' ', '_', strtolower($store->getStoreLabel()))); $loggerPath = sprintf('%s/%s.log', $this->logPath, $loggerName); $log = new Logger($loggerName); $log->pushHandler(new StreamHandler($loggerPath, $this->logLevel)); $subscriber = new LogSubscriber($log); $client->getEmitter()->attach($subscriber); return $client; }
public function mockShopifyApiClient(KernelInterface $kernel) { $shopClientFactory = $this->getMockBuilder('\\ERPBundle\\Factory\\Client\\ShopifyApiClientFactory')->disableOriginalConstructor()->getMock(); $shopifyApiClient = new ShopifyClient(array("shopUrl" => 'myStore', "X-Shopify-Access-Token" => 'MyAccessToken')); $mock = new Mock(); $shopifyApiClient->getEmitter()->attach($mock); $shopClientFactory->expects($this->any())->method('createClient')->willReturn($shopifyApiClient); $kernel->getContainer()->set('erp.guzzle.client.shopify', $shopClientFactory); return $mock; }