Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

namespace & tests fix

  • Loading branch information...
commit cc9fc8a31b650edc94d73cafa6644e7990cf5d5c 1 parent f028575
@fprochazka fprochazka authored
View
21 autoload.php
@@ -20,19 +20,22 @@
// libraries
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
- 'Kdyby\\Tests' => __DIR__ . '/tests',
- 'Kdyby' => __DIR__ . '/libs',
- 'Symfony' => __DIR__ . '/vendor/symfony/src',
- 'Doctrine\\Common' => __DIR__ . '/vendor/doctrine-common/lib',
- 'Doctrine\\DBAL\\Migrations' => __DIR__ . '/vendor/doctrine-migrations/lib',
- 'Doctrine\\DBAL' => __DIR__ . '/vendor/doctrine-dbal/lib',
- 'Doctrine\\ORM' => __DIR__ . '/vendor/doctrine/lib',
+ 'Kdyby\\Tests' => __DIR__ . '/tests',
+ 'Kdyby' => __DIR__ . '/libs',
+ 'Symfony' => __DIR__ . '/vendor/symfony/src',
+ 'Doctrine\\Common\\DataFixtures' => __DIR__ . '/vendor/doctrine-data-fixtures/lib',
+ 'Doctrine\\Common' => __DIR__ . '/vendor/doctrine-common/lib',
+ 'Doctrine\\DBAL\\Migrations' => __DIR__ . '/vendor/doctrine-migrations/lib',
+ 'Doctrine\\DBAL' => __DIR__ . '/vendor/doctrine-dbal/lib',
+ 'Doctrine\\ORM' => __DIR__ . '/vendor/doctrine/lib',
+ 'DoctrineExtensions' => __DIR__ . '/vendor/doctrine-extensions/lib',
+ 'Gedmo' => __DIR__ . '/vendor/doctrine-gedmo/lib',
));
$loader->register();
// annotations
AnnotationRegistry::registerLoader(function($class) use ($loader) {
- $loader->loadClass($class);
- return class_exists($class, FALSE);
+ $loader->loadClass($class);
+ return class_exists($class, FALSE);
});
AnnotationRegistry::registerFile(__DIR__ . '/vendor/doctrine/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
View
1  libs/Kdyby/DI/Extension.php
@@ -15,7 +15,6 @@
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
-use Symfony\Component\DependencyInjection\Container;
View
8 libs/Kdyby/Security/SimpleAuthenticator.php
@@ -22,13 +22,13 @@
class SimpleAuthenticator extends Nette\Object implements Nette\Security\IAuthenticator
{
- /** @var IIdentity */
+ /** @var \Nette\Security\IIdentity */
private $identity;
/**
- * @param IIdentity $identity
+ * @param \Nette\Security\IIdentity $identity
*/
public function __construct(IIdentity $identity)
{
@@ -39,7 +39,7 @@ public function __construct(IIdentity $identity)
/**
* @param array $credentials
- * @return IIdentity
+ * @return \Nette\Security\IIdentity
*/
public function authenticate(array $credentials)
{
@@ -47,4 +47,4 @@ public function authenticate(array $credentials)
}
-}
+}
View
14 libs/Kdyby/Tests/ORM/MemoryDatabaseManager.php
@@ -21,7 +21,7 @@
class MemoryDatabaseManager extends Nette\Object
{
- /** @var Nette\DI\Container */
+ /** @var \Kdyby\DI\SystemContainer */
protected $context;
/** @var Doctrine\Common\Cache\AbstractCache */
@@ -33,9 +33,9 @@ class MemoryDatabaseManager extends Nette\Object
/**
- * @param Nette\DI\Container $context
+ * @param \Kdyby\DI\SystemContainer $context
*/
- public function __construct(Nette\DI\Container $context)
+ public function __construct(Kdyby\DI\SystemContainer $context)
{
$this->context = $context;
$this->cache = new Kdyby\Doctrine\Cache(new Nette\Caching\Storages\MemoryStorage);
@@ -45,7 +45,7 @@ public function __construct(Nette\DI\Container $context)
/**
* @param array $entities
- * @return Sandbox
+ * @return \Kdyby\Tests\ORM\Sandbox
*/
public function refresh(array $entities = NULL)
{
@@ -58,7 +58,7 @@ public function refresh(array $entities = NULL)
/**
* @param array $entities
- * @return SandboxRecycler
+ * @return \Kdyby\Tests\ORM\SandboxRecycler
*/
private function getRecycler(array $entities = NULL)
{
@@ -78,7 +78,7 @@ private function getRecycler(array $entities = NULL)
/**
* @param array $entities
- * @return ISandboxBuilder
+ * @return \Kdyby\Tests\ORM\ISandboxBuilder
*/
protected function doCreateSandboxRecycler(array $entities)
{
@@ -96,4 +96,4 @@ protected function doCreateSandboxRecycler(array $entities)
}
-}
+}
View
38 libs/Kdyby/Tests/ORM/SandboxBuilder.php
@@ -36,7 +36,7 @@ class SandboxBuilder extends Nette\Object implements ISandboxBuilder
'host' => 'localhost',
'charset' => 'utf8',
'driver' => 'pdo_mysql',
- 'entityDirs' => array('%appDir%', '%kdybyFrameworkDir%'),
+ 'entityDirs' => array('%appDir%'),
'proxiesDir' => '%tempDir%/proxies',
'proxyNamespace' => 'Kdyby\Domain\Proxies',
'listeners' => array()
@@ -48,7 +48,7 @@ class SandboxBuilder extends Nette\Object implements ISandboxBuilder
Type::PASSWORD => 'Kdyby\Doctrine\Types\Password'
);
- /** @var AbstractCache */
+ /** @var \Doctrine\Common\Cache\AbstractCache */
public $cache;
/** @var boolean */
@@ -72,17 +72,21 @@ class SandboxBuilder extends Nette\Object implements ISandboxBuilder
/**
- * @param AbstractCache $cache
+ * @param \Doctrine\Common\Cache\AbstractCache $cache
*/
public function __construct(AbstractCache $cache)
{
$this->cache = $cache;
- if (defined('KDYBY_CMS_DIR')) {
- $this->params['entityDirs'][] = '%kdybyCmsDir%';
+ $this->params['entityDirs'] = array(
+ '%appDir%',
+ dirname(Nette\Reflection\ClassType::from('Kdyby\Framework')->getFileName())
+ );
+
+ if (class_exists('Kdyby\CMS')) {
+ $this->params['entityDirs'][] = dirname(Nette\Reflection\ClassType::from('Kdyby\CMS')->getFileName());
}
$this->registerTypes();
- $this->registerAnnotationClasses();
}
@@ -101,23 +105,9 @@ public function registerTypes()
/**
+ * @param \Kdyby\DI\SystemContainer $container
*/
- public function registerAnnotationClasses()
- {
- $loader = Kdyby\Loaders\SplClassLoader::getInstance();
- foreach ($loader->getTypeDirs('Doctrine\ORM') as $dir) {
- AnnotationRegistry::registerFile($dir . '/Mapping/Driver/DoctrineAnnotations.php');
- }
-
- AnnotationRegistry::registerFile(KDYBY_FRAMEWORK_DIR . '/Doctrine/Mapping/Driver/DoctrineAnnotations.php');
- }
-
-
-
- /**
- * @param Nette\DI\Container $container
- */
- public function expandParams(Nette\DI\Container $container)
+ public function expandParams(Kdyby\DI\SystemContainer $container)
{
array_walk_recursive($this->params, function (&$value, $key) use ($container) {
$value = $container->expand($value);
@@ -127,7 +117,7 @@ public function expandParams(Nette\DI\Container $container)
/**
- * @return AbstractCache
+ * @return \Doctrine\Common\Cache\AbstractCache
*/
protected function getCache()
{
@@ -328,4 +318,4 @@ protected function createDbalConnection()
);
}
-}
+}
View
42 tests/Kdyby/Tests/Security/UserMockBuilder.php
@@ -11,9 +11,9 @@
namespace Kdyby\Tests\Security;
use Kdyby;
-use Kdyby\Security\User;
use Kdyby\Tests\TestCase;
use Nette;
+use Nette\Http\User;
use Nette\Http\SessionSection;
use Nette\Security\IIdentity;
use Nette\Security\IAuthorizator;
@@ -26,25 +26,25 @@
class UserMockBuilder extends Nette\Object
{
- /** @var TestCase */
+ /** @var \Kdyby\Tests\TestCase */
private $test;
- /** @var Nette\ArrayHash */
+ /** @var \Nette\ArrayHash */
private $meta;
- /** @var Nette\ArrayHash */
+ /** @var \Nette\ArrayHash */
private $data;
- /** @var SessionSection */
+ /** @var \Nette\Http\SessionSection */
private $section;
- /** @var Nette\Http\Session */
+ /** @var \Nette\Http\Session */
private $session;
/**
- * @param TestCase $test
+ * @param \Kdyby\Tests\TestCase $test
*/
public function __construct(TestCase $test)
{
@@ -54,7 +54,7 @@ public function __construct(TestCase $test)
/**
- * @return Nette\ArrayHash
+ * @return \Nette\ArrayHash
*/
public function getMeta()
{
@@ -64,7 +64,7 @@ public function getMeta()
/**
- * @return Nette\ArrayHash
+ * @return \Nette\ArrayHash
*/
public function getData()
{
@@ -74,7 +74,7 @@ public function getData()
/**
- * @return Nette\ArrayHash
+ * @return \Nette\ArrayHash
*/
public function getSessionSection()
{
@@ -84,7 +84,7 @@ public function getSessionSection()
/**
- * @return Nette\Http\Session
+ * @return \Nette\Http\Session
*/
public function getSession()
{
@@ -94,10 +94,10 @@ public function getSession()
/**
- * @param IIdentity $identity
- * @param IAuthorizator $permission
+ * @param \Nette\Security\IIdentity $identity
+ * @param \Nette\Security\IAuthorizator $permission
* @param string $userNamespace
- * @return User
+ * @return \Nette\Http\User
*/
public function create(IIdentity $identity, IAuthorizator $permission, $userNamespace = '')
{
@@ -107,7 +107,7 @@ public function create(IIdentity $identity, IAuthorizator $permission, $userName
$context->addService('authenticator', new Kdyby\Security\SimpleAuthenticator($identity));
$context->addService('authorizator', $permission);
$context->addService('session', $this->session);
- $user = new User($context);
+ $user = new Nette\Http\User($context);
$sectionName = 'Nette.Web.User/' . $userNamespace;
$section = new SessionSection($this->session, $sectionName);
@@ -124,7 +124,8 @@ public function create(IIdentity $identity, IAuthorizator $permission, $userName
/**
* @hack Makes session shut up and act like array storage
- * @param SessionSection $section
+ *
+ * @param \Nette\Http\SessionSection $section
*/
private function injectMetaAndData(SessionSection $section)
{
@@ -141,14 +142,15 @@ private function injectMetaAndData(SessionSection $section)
/**
* @hack Makes user shut up and don't touch the session
- * @param User $user
- * @param SessionSection $section
+ *
+ * @param \Nette\Http\User $user
+ * @param \Nette\Http\SessionSection $section
*/
private function injectSection(User $user, SessionSection $section)
{
- $sessionRefl = $user->getReflection()->getParentClass()->getProperty('session');
+ $sessionRefl = $user->getReflection()->getProperty('session');
$sessionRefl->setAccessible(TRUE);
$sessionRefl->setValue($user, $this->section = $section);
}
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.