change phpdoc api generator to phpdoc

This commit is contained in:
Manuel Raynaud
2013-08-08 13:26:49 +02:00
parent a70ea40c3e
commit df371355b9
3674 changed files with 3538567 additions and 1503017 deletions

View File

@@ -0,0 +1,290 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Action;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Thelia\Core\Event\DefaultActionEvent;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Core\HttpFoundation\Session\Session;
use Thelia\Model\Cart;
use Thelia\Model\Customer;
use Thelia\Model\ProductQuery;
use Thelia\Model\ProductSaleElementsQuery;
class CartTest extends \PHPUnit_Framework_TestCase
{
protected $session;
protected $request;
protected $actionCart;
protected $uniqid;
public function setUp()
{
$this->session = new Session(new MockArraySessionStorage());
$this->request = new Request();
$this->request->setSession($this->session);
$this->uniqid = uniqid('', true);
$dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface");
$this->actionCart = $this->getMock(
"\Thelia\Action\Cart",
array("generateCookie", "redirect"),
array($dispatcher)
);
$this->actionCart
->expects($this->any())
->method("generateCookie")
->will($this->returnValue($this->uniqid));
$this->actionCart
->expects($this->any())
->method("redirect")
->will($this->returnValue(true))
;
}
/**
* no cart present in session and cart_id no yet exists in cookies.
*
* In this case, a new cart instance must be create
*/
public function testGetCartWithoutCustomerAndWithoutExistingCart()
{
$actionCart = $this->actionCart;
$cart = $actionCart->getCart($this->request);
$this->assertInstanceOf("Thelia\Model\Cart", $cart, '$cart must be an instance of cart model Thelia\Model\Cart');
$this->assertNull($cart->getCustomerId());
$this->assertNull($cart->getAddressDeliveryId());
$this->assertNull($cart->getAddressInvoiceId());
$this->assertEquals($this->uniqid, $cart->getToken());
}
/**
* Customer is connected but his cart does not exists yet
*
* Cart must be created and associated to the current connected Customer
*/
public function testGetCartWithCustomerAndWithoutExistingCart()
{
$actionCart = $this->actionCart;
$request = $this->request;
//create a fake customer just for test. If not persists test fails !
$customer = new Customer();
$customer->setFirstname("john");
$customer->setLastname("doe");
$customer->setTitleId(1);
$customer->save();
$request->getSession()->setCustomerUser($customer);
$cart = $actionCart->getCart($request);
$this->assertInstanceOf("Thelia\Model\Cart", $cart, '$cart must be an instance of cart model Thelia\Model\Cart');
$this->assertNotNull($cart->getCustomerId());
$this->assertEquals($customer->getId(), $cart->getCustomerId());
$this->assertNull($cart->getAddressDeliveryId());
$this->assertNull($cart->getAddressInvoiceId());
$this->assertEquals($this->uniqid, $cart->getToken());
}
/**
* Cart exists and his id put in cookies.
*
* Must return the same cart instance
*/
public function testGetCartWithoutCustomerAndWithExistingCart()
{
$actionCart = $this->actionCart;
$request = $this->request;
$uniqid = uniqid("test1", true);
//create a fake cart in database;
$cart = new Cart();
$cart->setToken($uniqid);
$cart->save();
$request->cookies->set("thelia_cart", $uniqid);
$getCart = $actionCart->getCart($request);
$this->assertInstanceOf("Thelia\Model\Cart", $getCart, '$cart must be an instance of cart model Thelia\Model\Cart');
$this->assertNull($getCart->getCustomerId());
$this->assertNull($getCart->getAddressDeliveryId());
$this->assertNull($getCart->getAddressInvoiceId());
$this->assertEquals($cart->getToken(), $getCart->getToken());
}
/**
* a cart id exists in cookies but this id does not exists yet in databases
*
* a new cart must be created (different token)
*/
public function testGetCartWithExistingCartButNotGoodCookies()
{
$actionCart = $this->actionCart;
$request = $this->request;
$token = "WrongToken";
$request->cookies->set("thelia_cart", $token);
$cart = $actionCart->getCart($request);
$this->assertInstanceOf("Thelia\Model\Cart", $cart, '$cart must be an instance of cart model Thelia\Model\Cart');
$this->assertNull($cart->getCustomerId());
$this->assertNull($cart->getAddressDeliveryId());
$this->assertNull($cart->getAddressInvoiceId());
$this->assertNotEquals($token, $cart->getToken());
}
/**
* cart and customer already exists. Cart and customer are linked.
*
* cart in session must be return
*/
public function testGetCartWithExistingCartAndCustomer()
{
$actionCart = $this->actionCart;
$request = $this->request;
//create a fake customer just for test. If not persists test fails !
$customer = new Customer();
$customer->setFirstname("john");
$customer->setLastname("doe");
$customer->setTitleId(1);
$customer->save();
$uniqid = uniqid("test2", true);
//create a fake cart in database;
$cart = new Cart();
$cart->setToken($uniqid);
$cart->setCustomer($customer);
$cart->save();
$request->cookies->set("thelia_cart", $uniqid);
$request->getSession()->setCustomerUser($customer);
$getCart = $actionCart->getCart($request);
$this->assertInstanceOf("Thelia\Model\Cart", $getCart, '$cart must be an instance of cart model Thelia\Model\Cart');
$this->assertNotNull($getCart->getCustomerId());
$this->assertNull($getCart->getAddressDeliveryId());
$this->assertNull($getCart->getAddressInvoiceId());
$this->assertEquals($cart->getToken(), $getCart->getToken(), "token must be the same");
$this->assertEquals($customer->getId(), $getCart->getCustomerId());
}
/**
* Customer is connected but cart not associated to him
*
* A new cart must be created (duplicated) containing customer id
*/
public function testGetCartWithExistingCartAndCustomerButNotSameCustomerId()
{
$actionCart = $this->actionCart;
$request = $this->request;
//create a fake customer just for test. If not persists test fails !
$customer = new Customer();
$customer->setFirstname("john");
$customer->setLastname("doe");
$customer->setTitleId(1);
$customer->save();
$uniqid = uniqid("test3", true);
//create a fake cart in database;
$cart = new Cart();
$cart->setToken($uniqid);
$cart->save();
$request->cookies->set("thelia_cart", $uniqid);
$request->getSession()->setCustomerUser($customer);
$getCart = $actionCart->getCart($request);
$this->assertInstanceOf("Thelia\Model\Cart", $getCart, '$cart must be an instance of cart model Thelia\Model\Cart');
$this->assertNotNull($getCart->getCustomerId());
$this->assertNull($getCart->getAddressDeliveryId());
$this->assertNull($getCart->getAddressInvoiceId());
$this->assertNotEquals($cart->getToken(), $getCart->getToken(), "token must be different");
$this->assertEquals($customer->getId(), $getCart->getCustomerId());
}
/**
* AddArticle action without data in the request, the form must not be valid
*/
/* public function testAddArticleWithError()
{
$actionEvent = new DefaultActionEvent($this->request, "AddArticle");
$this->actionCart->addArticle($actionEvent);
$this->assertTrue($actionEvent->hasErrorForm(), "no data in the request, so the action must failed and a form error must be present");
}*/
/* public function testAddArticleWithValidDataInRequest()
{
$request = $this->request;
$actionCart = $this->actionCart;
//find valid product
$product = ProductQuery::create()->findOne();
$productSalementElements = ProductSaleElementsQuery::create()->filterByProduct($product)->findOne();
$request->query->set("thelia_cart_add[product]", $product->getId());
$request->query->set("thelia_cart_add[product_sale_elements_id]", $productSalementElements->getId());
$request->query->set("thelia_cart_add[quantity]", 1);
$request->setMethod('GET');
$actionEvent = new DefaultActionEvent($request, "AddArticle");
$actionCart->addArticle($actionEvent);
$this->assertFalse($actionEvent->hasErrorForm(), "there is data in the request, form must be valid");
}*/
}

View File

@@ -0,0 +1,33 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Command;
abstract class BaseCommandTest extends \PHPUnit_Framework_TestCase {
public function getKernel()
{
$kernel = $this->getMock("Symfony\Component\HttpKernel\KernelInterface");
return $kernel;
}
}

View File

@@ -0,0 +1,107 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Command;
use Symfony\Component\Console\Tester\CommandTester;
use Thelia\Core\Application;
use Thelia\Command\CacheClear;
use Symfony\Component\Filesystem\Filesystem;
class CacheClearTest extends \PHPUnit_Framework_TestCase
{
public $cache_dir;
public function setUp()
{
$this->cache_dir = THELIA_ROOT . "cache/test";
$fs = new Filesystem();
$fs->mkdir($this->cache_dir);
}
public function testCacheClear()
{
$application = new Application($this->getKernel());
$cacheClear = new CacheClear();
$cacheClear->setContainer($this->getContainer());
$application->add($cacheClear);
$command = $application->find("cache:clear");
$commandTester = new CommandTester($command);
$commandTester->execute(array(
"command" => $command->getName(),
"--env" => "test"
));
$fs = new Filesystem();
$this->assertFalse($fs->exists($this->cache_dir));
}
/**
* @expectedException \RuntimeException
*/
public function testCacheClearWithoutWritePermission()
{
$fs = new Filesystem();
$fs->chmod($this->cache_dir,0100);
$application = new Application($this->getKernel());
$cacheClear = new CacheClear();
$cacheClear->setContainer($this->getContainer());
$application->add($cacheClear);
$command = $application->find("cache:clear");
$commandTester = new CommandTester($command);
$commandTester->execute(array(
"command" => $command->getName(),
"--env" => "test"
));
}
public function getKernel()
{
$kernel = $this->getMock("Symfony\Component\HttpKernel\KernelInterface");
return $kernel;
}
public function getContainer()
{
$container = new \Symfony\Component\DependencyInjection\ContainerBuilder();
$container->setParameter("kernel.cache_dir", $this->cache_dir);
return $container;
}
}

View File

@@ -0,0 +1,108 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Command;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Filesystem\Filesystem;
use Thelia\Core\Application;
use Thelia\Command\ModuleGenerateCommand;
class ModuleGenerateCommandTest extends BaseCommandTest {
protected $command;
protected $commandTester;
public static function clearTest()
{
$fs = new Filesystem();
if ($fs->exists(THELIA_MODULE_DIR . "Test")) {
$fs->remove(THELIA_MODULE_DIR . "Test");
}
}
public static function setUpBeforeClass()
{
self::clearTest();
}
public static function tearDownAfterClass()
{
self::clearTest();
}
public function setUp()
{
$application = new Application($this->getKernel());
$moduleGenerator = new ModuleGenerateCommand();
$application->add($moduleGenerator);
$this->command = $application->find("module:generate");
$this->commandTester = new CommandTester($this->command);
}
public function testGenerateModule()
{
$tester = $this->commandTester;
$tester->execute(array(
"command" => $this->command->getName(),
"name" => "test"
));
$fs = new Filesystem();
$this->assertTrue($fs->exists(THELIA_MODULE_DIR . "Test"));
}
/**
* @depends testGenerateModule
* @expectedException \RuntimeException
*/
public function testGenerateDuplicateModule()
{
$tester = $this->commandTester;
$tester->execute(array(
"command" => $this->command->getName(),
"name" => "test"
));
}
/**
* @expectedException \RuntimeException
*/
public function testGenerateWithReservedKeyWord()
{
$tester = $this->commandTester;
$tester->execute(array(
"command" => $this->command->getName(),
"name" => "thelia"
));
}
}

View File

@@ -0,0 +1,64 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Controller;
use Symfony\Component\HttpFoundation\Request;
use Thelia\Controller\DefaultController;
class DefaultControllerTest extends \PHPUnit_Framework_TestCase
{
public function testNoAction()
{
$defaultController = new DefaultController();
$request = new Request();
$defaultController->noAction($request);
$this->assertEquals($request->attributes->get('_view'), "index");
}
public function testNoActionWithQuery()
{
$defaultController = new DefaultController();
$request = new Request(array(
"view" => "foo"
));
$defaultController->noAction($request);
$this->assertEquals($request->attributes->get('_view'), 'foo');
}
public function testNoActionWithRequest()
{
$defaultController = new DefaultController();
$request = new Request(array(), array(
"view" => "foo"
));
$defaultController->noAction($request);
$this->assertEquals($request->attributes->get('_view'), 'foo');
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace Thelia\Tests\Core\HttpFoundation;
use Thelia\Core\HttpFoundation\Request;
class RequestTest extends \PHPUnit_Framework_TestCase
{
public function testGetUriAddingParameters()
{
$request = $this->getMock(
"Thelia\Core\HttpFoundation\Request",
array("getUri", "getQueryString")
);
$request->expects($this->any())
->method("getUri")
->will($this->onConsecutiveCalls(
"http://localhost/",
"http://localhost/?test=fu"
));
$request->expects($this->any())
->method("getQueryString")
->will($this->onConsecutiveCalls(
"",
"test=fu"
));
$result = $request->getUriAddingParameters(array("foo" => "bar"));
$this->assertEquals("http://localhost/?foo=bar", $result);
$result = $request->getUriAddingParameters(array("foo" => "bar"));
$this->assertEquals("http://localhost/?test=fu&foo=bar", $result);
}
}

View File

@@ -0,0 +1,136 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Core\HttpFoundation\Session;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Thelia\Core\HttpFoundation\Session\Session;
use Thelia\Model\Cart;
use Thelia\Model\Customer;
class SessionTest extends \PHPUnit_Framework_TestCase
{
protected $session;
public function setUp()
{
$this->session = new Session(new MockArraySessionStorage());
}
public function testGetCartWithoutExistingCart()
{
$session = $this->session;
$cart = $session->getCart();
$this->assertNull($cart);
}
public function testGetCartWithExistingCartWithoutCustomerConnected()
{
$session = $this->session;
$testCart = new Cart();
$testCart->setToken(uniqid("testSessionGetCart1", true));
$testCart->save();
$session->setCart($testCart->getId());
$cart = $session->getCart();
$this->assertNotNull($cart);
$this->assertInstanceOf("\Thelia\Model\Cart", $cart, '$cart must be an instance of Thelia\Model\Cart');
$this->assertEquals($testCart->getToken(), $cart->getToken());
}
public function testGetCartWithExistingCustomerButNoCart()
{
$session = $this->session;
//create a fake customer just for test. If not persists test fails !
$customer = new Customer();
$customer->setFirstname("john test session");
$customer->setLastname("doe");
$customer->setTitleId(1);
$customer->save();
$session->setCustomerUser($customer);
$cart = $session->getCart();
$this->assertNull($cart);
}
public function testGetCartWithExistingCartAndCustomerButWithoutReferenceToCustomerInCart()
{
$session = $this->session;
//create a fake customer just for test. If not persists test fails !
$customer = new Customer();
$customer->setFirstname("john test session");
$customer->setLastname("doe");
$customer->setTitleId(1);
$customer->save();
$session->setCustomerUser($customer);
$testCart = new Cart();
$testCart->setToken(uniqid("testSessionGetCart2", true));
$testCart->save();
$session->setCart($testCart->getId());
$cart = $session->getCart();
$this->assertNull($cart);
}
public function testGetCartWithExistingCartAndCustomerAndReferencesEachOther()
{
$session = $this->session;
//create a fake customer just for test. If not persists test fails !
$customer = new Customer();
$customer->setFirstname("john test session");
$customer->setLastname("doe");
$customer->setTitleId(1);
$customer->save();
$session->setCustomerUser($customer);
$testCart = new Cart();
$testCart->setToken(uniqid("testSessionGetCart3", true));
$testCart->setCustomerId($customer->getId());
$testCart->save();
$session->setCart($testCart->getId());
$cart = $session->getCart();
$this->assertNotNull($cart);
$this->assertInstanceOf("\Thelia\Model\Cart", $cart, '$cart must be an instance of Thelia\Model\Cart');
}
}

View File

@@ -0,0 +1,87 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Core\Template\Element;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Core\Security\SecurityContext;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Thelia\Core\HttpFoundation\Session\Session;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
abstract class BaseLoopTestor extends \PHPUnit_Framework_TestCase
{
protected $request;
protected $dispatcher;
protected $securityContext;
protected $instance;
abstract public function getTestedClassName();
abstract public function getTestedInstance();
abstract public function getMandatoryArguments();
protected function getMethod($name) {
$class = new \ReflectionClass($this->getTestedClassName());
$method = $class->getMethod($name);
$method->setAccessible(true);
return $method;
}
public function setUp()
{
$this->request = new Request();
$this->request->setSession(new Session(new MockArraySessionStorage()));
$this->dispatcher = new EventDispatcher();
$this->securityContext = new SecurityContext($this->request);
$this->instance = $this->getTestedInstance();
$this->instance->initializeArgs($this->getMandatoryArguments());
}
public function testGetArgDefinitions()
{
$method = $this->getMethod('getArgDefinitions');
$methodReturn = $method->invoke($this->instance);
$this->assertInstanceOf('Thelia\Core\Template\Loop\Argument\ArgumentCollection', $methodReturn);
}
public function testExec()
{
$method = $this->getMethod('exec');
$methodReturn = $method->invokeArgs($this->instance, array(null));
$this->assertInstanceOf('\Thelia\Core\Template\Element\LoopResult', $methodReturn);
}
}

View File

@@ -0,0 +1,52 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Core\Template\Loop;
use Thelia\Tests\Core\Template\Element\BaseLoopTestor;
use Thelia\Core\Template\Loop\Accessory;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class AccessoryTest extends BaseLoopTestor
{
public function getTestedClassName()
{
return 'Thelia\Core\Template\Loop\Accessory';
}
public function getTestedInstance()
{
return new Accessory($this->request, $this->dispatcher, $this->securityContext);
}
public function getMandatoryArguments()
{
return array('product' => 1);
}
}

View File

@@ -0,0 +1,52 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Core\Template\Loop;
use Thelia\Tests\Core\Template\Element\BaseLoopTestor;
use Thelia\Core\Template\Loop\Address;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class AddressTest extends BaseLoopTestor
{
public function getTestedClassName()
{
return 'Thelia\Core\Template\Loop\Address';
}
public function getTestedInstance()
{
return new Address($this->request, $this->dispatcher, $this->securityContext);
}
public function getMandatoryArguments()
{
return array();
}
}

View File

@@ -0,0 +1,113 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Core\Template\Loop\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Type;
use Thelia\Type\TypeCollection;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class ArgumentTest extends \PHPUnit_Framework_TestCase
{
public function testArgumentCollectionCreateAndWalk()
{
$collection = new ArgumentCollection(
new Argument(
'arg0',
new TypeCollection(
new Type\AnyType()
)
),
new Argument(
'arg1',
new TypeCollection(
new Type\AnyType()
)
)
);
$collection->addArgument(
new Argument(
'arg2',
new TypeCollection(
new Type\AnyType()
)
)
);
$this->assertTrue($collection->getCount() == 3);
$this->assertTrue($collection->key() == 'arg0');
$collection->next();
$this->assertTrue($collection->key() == 'arg1');
$collection->next();
$this->assertTrue($collection->key() == 'arg2');
$collection->next();
$this->assertFalse($collection->valid());
$collection->rewind();
$this->assertTrue($collection->key() == 'arg0');
}
public function testArgumentCollectionFetch()
{
$collection = new ArgumentCollection(
new Argument(
'arg0',
new TypeCollection(
new Type\AnyType()
)
),
new Argument(
'arg1',
new TypeCollection(
new Type\AnyType()
)
),
new Argument(
'arg2',
new TypeCollection(
new Type\AnyType()
)
)
);
$arguments = \PHPUnit_Framework_Assert::readAttribute($collection, 'arguments');
foreach($collection as $key => $argument) {
$this->assertEquals(
$argument,
$arguments[$key]
);
}
}
}

View File

@@ -0,0 +1,52 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Core\Template\Loop;
use Thelia\Tests\Core\Template\Element\BaseLoopTestor;
use Thelia\Core\Template\Loop\Category;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class CategoryTest extends BaseLoopTestor
{
public function getTestedClassName()
{
return 'Thelia\Core\Template\Loop\Category';
}
public function getTestedInstance()
{
return new Category($this->request, $this->dispatcher, $this->securityContext);
}
public function getMandatoryArguments()
{
return array();
}
}

View File

@@ -0,0 +1,52 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Core\Template\Loop;
use Thelia\Tests\Core\Template\Element\BaseLoopTestor;
use Thelia\Core\Template\Loop\Content;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class ContentTest extends BaseLoopTestor
{
public function getTestedClassName()
{
return 'Thelia\Core\Template\Loop\Content';
}
public function getTestedInstance()
{
return new Content($this->request, $this->dispatcher, $this->securityContext);
}
public function getMandatoryArguments()
{
return array();
}
}

View File

@@ -0,0 +1,52 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Core\Template\Loop;
use Thelia\Tests\Core\Template\Element\BaseLoopTestor;
use Thelia\Core\Template\Loop\Country;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class CountryTest extends BaseLoopTestor
{
public function getTestedClassName()
{
return 'Thelia\Core\Template\Loop\Country';
}
public function getTestedInstance()
{
return new Country($this->request, $this->dispatcher, $this->securityContext);
}
public function getMandatoryArguments()
{
return array();
}
}

View File

@@ -0,0 +1,52 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Core\Template\Loop;
use Thelia\Tests\Core\Template\Element\BaseLoopTestor;
use Thelia\Core\Template\Loop\Customer;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class CustomerTest extends BaseLoopTestor
{
public function getTestedClassName()
{
return 'Thelia\Core\Template\Loop\Customer';
}
public function getTestedInstance()
{
return new Customer($this->request, $this->dispatcher, $this->securityContext);
}
public function getMandatoryArguments()
{
return array();
}
}

View File

@@ -0,0 +1,52 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Core\Template\Loop;
use Thelia\Tests\Core\Template\Element\BaseLoopTestor;
use Thelia\Core\Template\Loop\FeatureAvailable;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class FeatureAvailableTest extends BaseLoopTestor
{
public function getTestedClassName()
{
return 'Thelia\Core\Template\Loop\FeatureAvailable';
}
public function getTestedInstance()
{
return new FeatureAvailable($this->request, $this->dispatcher, $this->securityContext);
}
public function getMandatoryArguments()
{
return array();
}
}

View File

@@ -0,0 +1,52 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Core\Template\Loop;
use Thelia\Tests\Core\Template\Element\BaseLoopTestor;
use Thelia\Core\Template\Loop\Feature;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class FeatureTest extends BaseLoopTestor
{
public function getTestedClassName()
{
return 'Thelia\Core\Template\Loop\Feature';
}
public function getTestedInstance()
{
return new Feature($this->request, $this->dispatcher, $this->securityContext);
}
public function getMandatoryArguments()
{
return array();
}
}

View File

@@ -0,0 +1,52 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Core\Template\Loop;
use Thelia\Tests\Core\Template\Element\BaseLoopTestor;
use Thelia\Core\Template\Loop\FeatureValue;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class FeatureValueTest extends BaseLoopTestor
{
public function getTestedClassName()
{
return 'Thelia\Core\Template\Loop\FeatureValue';
}
public function getTestedInstance()
{
return new FeatureValue($this->request, $this->dispatcher, $this->securityContext);
}
public function getMandatoryArguments()
{
return array('product' => 1, 'feature' => 1);
}
}

View File

@@ -0,0 +1,52 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Core\Template\Loop;
use Thelia\Tests\Core\Template\Element\BaseLoopTestor;
use Thelia\Core\Template\Loop\Folder;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class FolderTest extends BaseLoopTestor
{
public function getTestedClassName()
{
return 'Thelia\Core\Template\Loop\Folder';
}
public function getTestedInstance()
{
return new Folder($this->request, $this->dispatcher, $this->securityContext);
}
public function getMandatoryArguments()
{
return array();
}
}

View File

@@ -0,0 +1,52 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Core\Template\Loop;
use Thelia\Tests\Core\Template\Element\BaseLoopTestor;
use Thelia\Core\Template\Loop\Product;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
/*class ProductTest extends BaseLoopTestor
{
public function getTestedClassName()
{
return 'Thelia\Core\Template\Loop\Product';
}
public function getTestedInstance()
{
return new Product($this->request, $this->dispatcher, $this->securityContext);
}
public function getMandatoryArguments()
{
return array();
}
}*/

View File

@@ -0,0 +1,52 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Core\Template\Loop;
use Thelia\Tests\Core\Template\Element\BaseLoopTestor;
use Thelia\Core\Template\Loop\Title;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class TitleTest extends BaseLoopTestor
{
public function getTestedClassName()
{
return 'Thelia\Core\Template\Loop\Title';
}
public function getTestedInstance()
{
return new Title($this->request, $this->dispatcher, $this->securityContext);
}
public function getMandatoryArguments()
{
return array();
}
}

View File

@@ -0,0 +1,25 @@
<?php
/* File generated by \Thelia\Config\Dumper\TpexConfigDumper */
class TpexConfig
{
public function getLoopConfig()
{
return array();
}
public function getFilterConfig()
{
return array();
}
public function getBaseParamConfig()
{
return array();
}
public function getLoopTestConfig()
{
return array();
}
}

View File

@@ -0,0 +1,33 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Form;
class CartAddTest extends \PHPUnit_Framework_TestCase
{
public function testSimpleAddingToCart()
{
}
}

View File

@@ -0,0 +1,205 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Log;
use Thelia\Log\Tlog;
class TlogTest extends \PHPUnit_Framework_TestCase
{
protected static $logger;
protected $regex = "/[0-9]+:[\s](%s)+[\s]\[[a-zA-Z\.]+:[a-zA-Z]+\(\)\][\s]\{[0-9]+\}[\s][0-9]{4}-[0-9]{2}-[0-9]{2}[\s][0-9]{1,2}:[0-9]{2}:[0-9]{2}:[\s](%s).*$/is";
public static function setUpBeforeClass()
{
self::$logger = Tlog::getInstance();
self::$logger->setDestinations("Thelia\Log\Destination\TlogDestinationText");
self::$logger->setLevel(Tlog::DEBUG);
self::$logger->setFiles("*");
}
public function testDebugWithDebugLevel()
{
$logger = self::$logger;
$logger->setLevel(Tlog::DEBUG);
//"#NUM: #NIVEAU [#FICHIER:#FONCTION()] {#LIGNE} #DATE #HEURE: "
$this->expectOutputRegex(sprintf($this->regex, "DEBUG", "foo"));
$logger->debug("foo");
}
public function testDebugWithoutDebugLevel()
{
$logger = self::$logger;
$logger->setLevel(Tlog::MUET);
$this->expectOutputRegex("/^$/");
$logger->debug("foo");
}
public function testDebugWithInfoLevel()
{
$logger = self::$logger;
$logger->setLevel(Tlog::INFO);
//"#NUM: #NIVEAU [#FICHIER:#FONCTION()] {#LIGNE} #DATE #HEURE: "
$this->expectOutputRegex(sprintf($this->regex, "INFO", "foo"));
$logger->info("foo");
}
public function testDebugWithoutInfoLevel()
{
$logger = self::$logger;
$logger->setLevel(Tlog::MUET);
$this->expectOutputRegex("/^$/");
$logger->info("foo");
}
public function testDebugWithNoticeLevel()
{
$logger = self::$logger;
$logger->setLevel(Tlog::NOTICE);
//"#NUM: #NIVEAU [#FICHIER:#FONCTION()] {#LIGNE} #DATE #HEURE: "
$this->expectOutputRegex(sprintf($this->regex, "NOTICE", "foo"));
$logger->notice("foo");
}
public function testDebugWithoutNoticeLevel()
{
$logger = self::$logger;
$logger->setLevel(Tlog::MUET);
$this->expectOutputRegex("/^$/");
$logger->notice("foo");
}
public function testWarningWithWarningLevel()
{
$logger = self::$logger;
$logger->setLevel(Tlog::WARNING);
//"#NUM: #NIVEAU [#FICHIER:#FONCTION()] {#LIGNE} #DATE #HEURE: "
$this->expectOutputRegex(sprintf($this->regex, "WARNING", "foo"));
$logger->warning("foo");
}
public function testWarningWithoutWarningLevel()
{
$logger = self::$logger;
$logger->setLevel(Tlog::MUET);
$this->expectOutputRegex("/^$/");
$logger->warning("foo");
}
public function testErrorWithErrorLevel()
{
$logger = self::$logger;
$logger->setLevel(Tlog::ERROR);
//"#NUM: #NIVEAU [#FICHIER:#FONCTION()] {#LIGNE} #DATE #HEURE: "
$this->expectOutputRegex(sprintf($this->regex, "ERROR", "foo"));
$logger->error("foo");
}
public function testErrorWithoutErrorLevel()
{
$logger = self::$logger;
$logger->setLevel(Tlog::MUET);
$this->expectOutputRegex("/^$/");
$logger->error("foo");
}
public function testErrorWithCriticalLevel()
{
$logger = self::$logger;
$logger->setLevel(Tlog::CRITICAL);
//"#NUM: #NIVEAU [#FICHIER:#FONCTION()] {#LIGNE} #DATE #HEURE: "
$this->expectOutputRegex(sprintf($this->regex, "CRITICAL", "foo"));
$logger->critical("foo");
}
public function testErrorWithoutCriticalLevel()
{
$logger = self::$logger;
$logger->setLevel(Tlog::MUET);
$this->expectOutputRegex("/^$/");
$logger->critical("foo");
}
public function testErrorWithAlertLevel()
{
$logger = self::$logger;
$logger->setLevel(Tlog::ALERT);
//"#NUM: #NIVEAU [#FICHIER:#FONCTION()] {#LIGNE} #DATE #HEURE: "
$this->expectOutputRegex(sprintf($this->regex, "ALERT", "foo"));
$logger->alert("foo");
}
public function testErrorWithoutAlertLevel()
{
$logger = self::$logger;
$logger->setLevel(Tlog::MUET);
$this->expectOutputRegex("/^$/");
$logger->alert("foo");
}
public function testErrorWithEmergencyLevel()
{
$logger = self::$logger;
$logger->setLevel(Tlog::EMERGENCY);
//"#NUM: #NIVEAU [#FICHIER:#FONCTION()] {#LIGNE} #DATE #HEURE: "
$this->expectOutputRegex(sprintf($this->regex, "EMERGENCY", "foo"));
$logger->emergency("foo");
}
public function testErrorWithoutEmergencyLevel()
{
$logger = self::$logger;
$logger->setLevel(Tlog::MUET);
$this->expectOutputRegex("/^$/");
$logger->emergency("foo");
}
}

View File

@@ -0,0 +1,49 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Type;
use Thelia\Type\AlphaNumStringListType;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class AlphaNumStringListTypeTest extends \PHPUnit_Framework_TestCase
{
public function testAlphaNumStringListType()
{
$type = new AlphaNumStringListType();
$this->assertTrue($type->isValid('FOO1,FOO_2,FOO-3'));
$this->assertFalse($type->isValid('FOO.1,FOO$_2,FOO-3'));
}
public function testFormatAlphaNumStringListType()
{
$type = new AlphaNumStringListType();
$this->assertTrue(is_array($type->getFormattedValue('FOO1,FOO_2,FOO-3')));
$this->assertNull($type->getFormattedValue('5€'));
}
}

View File

@@ -0,0 +1,44 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Type;
use Thelia\Type\AlphaNumStringType;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class AlphaNumStringTypeTest extends \PHPUnit_Framework_TestCase
{
public function testAlphaNumStringType()
{
$type = new AlphaNumStringType();
$this->assertTrue($type->isValid('azs_qs-0-9ds'));
$this->assertFalse($type->isValid('3.3'));
$this->assertFalse($type->isValid('3 3'));
$this->assertFalse($type->isValid('3€3'));
}
}

View File

@@ -0,0 +1,41 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Type;
use Thelia\Type\AnyType;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class AnyTypeTest extends \PHPUnit_Framework_TestCase
{
public function testAnyType()
{
$anyType = new AnyType();
$this->assertTrue($anyType->isValid(md5(rand(1000, 10000))));
}
}

View File

@@ -0,0 +1,58 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Type;
use Thelia\Type\BooleanType;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class BooleanTypeTest extends \PHPUnit_Framework_TestCase
{
public function testBooleanType()
{
$booleanType = new BooleanType();
$this->assertTrue($booleanType->isValid('1'));
$this->assertTrue($booleanType->isValid('yes'));
$this->assertTrue($booleanType->isValid('true'));
$this->assertTrue($booleanType->isValid('no'));
$this->assertTrue($booleanType->isValid('off'));
$this->assertTrue($booleanType->isValid(1));
$this->assertTrue($booleanType->isValid('false'));
$this->assertFalse($booleanType->isValid('foo'));
$this->assertFalse($booleanType->isValid(2));
}
public function testFormatBooleanType()
{
$booleanType = new BooleanType();
$this->assertTrue($booleanType->getFormattedValue('on'));
$this->assertFalse($booleanType->getFormattedValue('0'));
$this->assertFalse($booleanType->getFormattedValue(0));
$this->assertNull($booleanType->getFormattedValue(3));
}
}

View File

@@ -0,0 +1,51 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Type;
use Thelia\Type\EnumListType;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class EnumListTypeTest extends \PHPUnit_Framework_TestCase
{
public function testEnumListType()
{
$enumListType = new EnumListType(array("cat", "dog", "frog"));
$this->assertTrue($enumListType->isValid('cat'));
$this->assertTrue($enumListType->isValid('cat,dog'));
$this->assertFalse($enumListType->isValid('potato'));
$this->assertFalse($enumListType->isValid('cat,monkey'));
}
public function testFormatEnumListType()
{
$enumListType = new EnumListType(array("cat", "dog", "frog"));
$this->assertTrue(is_array($enumListType->getFormattedValue('cat,dog')));
$this->assertNull($enumListType->getFormattedValue('cat,monkey'));
}
}

View File

@@ -0,0 +1,44 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Type;
use Thelia\Type\EnumType;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class EnumTypeTest extends \PHPUnit_Framework_TestCase
{
public function testEnumType()
{
$enumType = new EnumType(array("cat", "dog"));
$this->assertTrue($enumType->isValid('cat'));
$this->assertTrue($enumType->isValid('dog'));
$this->assertFalse($enumType->isValid('monkey'));
$this->assertFalse($enumType->isValid('catdog'));
}
}

View File

@@ -0,0 +1,43 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Type;
use Thelia\Type\FloatType;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class FloatTypeTest extends \PHPUnit_Framework_TestCase
{
public function testFloatType()
{
$floatType = new FloatType();
$this->assertTrue($floatType->isValid('1.1'));
$this->assertTrue($floatType->isValid(2.2));
$this->assertFalse($floatType->isValid('foo'));
}
}

View File

@@ -0,0 +1,50 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Type;
use Thelia\Type\IntListType;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class IntListTypeTest extends \PHPUnit_Framework_TestCase
{
public function testIntListType()
{
$intListType = new IntListType();
$this->assertTrue($intListType->isValid('1'));
$this->assertTrue($intListType->isValid('1,2,3'));
$this->assertFalse($intListType->isValid('1,2,3.3'));
}
public function testFormatIntListType()
{
$intListType = new IntListType();
$this->assertTrue(is_array($intListType->getFormattedValue('1,2,3')));
$this->assertNull($intListType->getFormattedValue('foo'));
}
}

View File

@@ -0,0 +1,65 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Type;
use Thelia\Type\IntToCombinedIntsListType;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class IntToCombinedIntsListTypeTest extends \PHPUnit_Framework_TestCase
{
public function testIntToCombinedIntsListType()
{
$type = new IntToCombinedIntsListType();
$this->assertTrue($type->isValid('1: 2 & 5 | (6 &7), 4: *, 67: (1 & 9)'));
$this->assertFalse($type->isValid('1,2,3'));
}
public function testFormatJsonType()
{
$type = new IntToCombinedIntsListType();
$this->assertEquals(
$type->getFormattedValue('1: 2 & 5 | (6 &7), 4: *, 67: (1 & 9)'),
array(
1 => array(
"values" => array(2,5,6,7),
"expression" => '2&5|(6&7)',
),
4 => array(
"values" => array('*'),
"expression" => '*',
),
67 => array(
"values" => array(1,9),
"expression" => '(1&9)',
),
)
);
$this->assertNull($type->getFormattedValue('foo'));
}
}

View File

@@ -0,0 +1,65 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Type;
use Thelia\Type\IntToCombinedStringsListType;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class IntToCombinedStringsListTypeTest extends \PHPUnit_Framework_TestCase
{
public function testIntToCombinedStringsListType()
{
$type = new IntToCombinedStringsListType();
$this->assertTrue($type->isValid('1: foo & bar | (fooo &baar), 4: *, 67: (foooo & baaar)'));
$this->assertFalse($type->isValid('1,2,3'));
}
public function testFormatJsonType()
{
$type = new IntToCombinedStringsListType();
$this->assertEquals(
$type->getFormattedValue('1: foo & bar | (fooo &baar), 4: *, 67: (foooo & baaar)'),
array(
1 => array(
"values" => array('foo','bar','fooo','baar'),
"expression" => 'foo&bar|(fooo&baar)',
),
4 => array(
"values" => array('*'),
"expression" => '*',
),
67 => array(
"values" => array('foooo','baaar'),
"expression" => '(foooo&baaar)',
),
)
);
$this->assertNull($type->getFormattedValue('foo'));
}
}

View File

@@ -0,0 +1,43 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Type;
use Thelia\Type\IntType;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class IntTypeTest extends \PHPUnit_Framework_TestCase
{
public function testIntType()
{
$intType = new IntType();
$this->assertTrue($intType->isValid('1'));
$this->assertTrue($intType->isValid(2));
$this->assertFalse($intType->isValid('3.3'));
}
}

View File

@@ -0,0 +1,49 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Type;
use Thelia\Type\JsonType;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class JsonTypeTest extends \PHPUnit_Framework_TestCase
{
public function testJsonType()
{
$jsonType = new JsonType();
$this->assertTrue($jsonType->isValid('{"k0":"v0","k1":"v1","k2":"v2"}'));
$this->assertFalse($jsonType->isValid('1,2,3'));
}
public function testFormatJsonType()
{
$jsonType = new JsonType();
$this->assertTrue(is_array($jsonType->getFormattedValue('{"k0":"v0","k1":"v1","k2":"v2"}')));
$this->assertNull($jsonType->getFormattedValue('foo'));
}
}

View File

@@ -0,0 +1,77 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Tests\Type;
use Thelia\Type;
use Thelia\Type\TypeCollection;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class TypeTest extends \PHPUnit_Framework_TestCase
{
public function testTypeCollectionConstruction()
{
$collection = new TypeCollection(
new Type\AnyType(),
new Type\IntType()
);
$collection->addType(
new Type\FloatType()
);
$this->assertAttributeEquals(
array(
new Type\AnyType(),
new Type\IntType(),
new Type\FloatType(),
),
'types',
$collection
);
}
public function testTypeCollectionFetch()
{
$collection = new TypeCollection(
new Type\AnyType(),
new Type\IntType(),
new Type\FloatType()
);
$types = \PHPUnit_Framework_Assert::readAttribute($collection, 'types');
foreach($collection as $key => $type) {
$this->assertEquals(
$type,
$types[$key]
);
}
}
}

View File

@@ -0,0 +1,18 @@
<?php
/**
*
* @file
* Functions needed for Thelia bootstrap
*/
$env = "test";
require_once __DIR__ . '/../../../bootstrap.php';
use Thelia\Core\Thelia;
$thelia = new Thelia("test", true);