Example #1
0
 public function testClearCache()
 {
     $kommerce = new DoctrineHelper(new Doctrine\Common\Cache\ArrayCache());
     $kommerce->setup(['driver' => 'pdo_sqlite', 'memory' => true]);
     $cacheDriver = $kommerce->getCacheDriver();
     $id = 'test-id';
     $data = 'test-data';
     $cacheDriver->save($id, $data);
     $this->assertSame($data, $cacheDriver->fetch($id));
     $kommerce->clearCache();
     $this->assertSame(false, $cacheDriver->fetch($id));
 }
Example #2
0
<?php

use Doctrine\ORM\Tools\Console\ConsoleRunner;
use inklabs\kommerce\Lib\DoctrineHelper;
require_once __DIR__ . '/../vendor/autoload.php';
$doctrineHelper = new DoctrineHelper(new Doctrine\Common\Cache\ArrayCache());
$doctrineHelper->setup(['driver' => 'pdo_sqlite', 'path' => __DIR__ . '/../storage/db.sqlite']);
$entityManager = $doctrineHelper->getEntityManager();
// Fix MySQL enum
$platform = $entityManager->getConnection()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string');
return ConsoleRunner::createHelperSet($entityManager);
 private function setupSqliteConnection()
 {
     $this->doctrineHelper->setup(['driver' => 'pdo_sqlite', 'memory' => true]);
     $this->doctrineHelper->addSqliteFunctions();
 }
 private function getEntityManager()
 {
     static $entityManager = null;
     if ($entityManager === null) {
         $cacheDriver = $this->getCacheDriver();
         $doctrineHelper = new DoctrineHelper($cacheDriver);
         $doctrineHelper->setup(['driver' => 'pdo_sqlite', 'path' => storage_path() . '/db.sqlite']);
         $doctrineHelper->addSqliteFunctions();
         $entityManager = $doctrineHelper->getEntityManager();
     }
     return $entityManager;
 }