public function setUp()
{
$config = new Configuration();
$config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('Proxies');
$reader = new AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\\ODM\\MongoDB\\Mapping\\');
$config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/Documents'));
$this->dm = DocumentManager::create(new Mongo(), $config);
$currencies = array('USD' => 1, 'EURO' => 1.7, 'JPN' => 0.0125);
foreach ($currencies as $name => &$multiplier) {
$multiplier = new Currency($name, $multiplier);
$this->dm->persist($multiplier);
}
$product = new ConfigurableProduct('T-Shirt');
$product->addOption(new Option('small', new Money(12.99, $currencies['USD']), new StockItem('T-shirt Size S', new Money(9.99, $currencies['USD']), 15)));
$product->addOption(new Option('medium', new Money(14.99, $currencies['USD']), new StockItem('T-shirt Size M', new Money(11.99, $currencies['USD']), 15)));
$product->addOption(new Option('large', new Money(17.99, $currencies['USD']), new StockItem('T-shirt Size L', new Money(13.99, $currencies['USD']), 15)));
$this->dm->persist($product);
$this->dm->flush();
foreach ($currencies as $currency) {
$this->dm->detach($currency);
}
$this->dm->detach($product);
unset($currencies, $product);
}