Vendor update && Started using DoctrineMigrations
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace JMS\DiExtraBundle\Tests\Functional;
|
||||
|
||||
require_once __DIR__.'/../bootstrap.php';
|
||||
|
||||
use Symfony\Component\HttpKernel\Util\Filesystem;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
|
||||
class AppKernel extends Kernel
|
||||
{
|
||||
private $config;
|
||||
|
||||
public function __construct($config)
|
||||
{
|
||||
parent::__construct('test', true);
|
||||
|
||||
$fs = new Filesystem();
|
||||
if (!$fs->isAbsolutePath($config)) {
|
||||
$config = __DIR__.'/config/'.$config;
|
||||
}
|
||||
|
||||
if (!file_exists($config)) {
|
||||
throw new \RuntimeException(sprintf('The config file "%s" does not exist.', $config));
|
||||
}
|
||||
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function registerBundles()
|
||||
{
|
||||
return array(
|
||||
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
|
||||
new \Symfony\Bundle\SecurityBundle\SecurityBundle(),
|
||||
new \Symfony\Bundle\TwigBundle\TwigBundle(),
|
||||
new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
|
||||
new \JMS\AopBundle\JMSAopBundle(),
|
||||
new \JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\JMSDiExtraTestBundle(),
|
||||
new \JMS\DiExtraBundle\JMSDiExtraBundle($this),
|
||||
new \JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
|
||||
);
|
||||
}
|
||||
|
||||
public function registerContainerConfiguration(LoaderInterface $loader)
|
||||
{
|
||||
$loader->load($this->config);
|
||||
}
|
||||
|
||||
public function getCacheDir()
|
||||
{
|
||||
return sys_get_temp_dir().'/JMSDiExtraBundle';
|
||||
}
|
||||
|
||||
public function serialize()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
public function unserialize($config)
|
||||
{
|
||||
$this->__construct($config);
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace JMS\DiExtraBundle\Tests\Functional;
|
||||
|
||||
use Symfony\Component\HttpKernel\Util\Filesystem;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
class BaseTestCase extends WebTestCase
|
||||
{
|
||||
static protected function createKernel(array $options = array())
|
||||
{
|
||||
return new AppKernel(
|
||||
isset($options['config']) ? $options['config'] : 'default.yml'
|
||||
);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->cleanTmpDir();
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->cleanTmpDir();
|
||||
}
|
||||
|
||||
private function cleanTmpDir()
|
||||
{
|
||||
$fs = new Filesystem();
|
||||
$fs->remove(sys_get_temp_dir().'/JMSDiExtraBundle');
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Controller;
|
||||
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use JMS\SecurityExtraBundle\Annotation\Secure;
|
||||
use JMS\DiExtraBundle\Annotation as DI;
|
||||
|
||||
/**
|
||||
* Secured Controller.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class AnotherSecuredController
|
||||
{
|
||||
/**
|
||||
* @Route("/secure-action")
|
||||
* @Secure("ROLE_FOO")
|
||||
*/
|
||||
public function secureAction()
|
||||
{
|
||||
throw new \Exception('Should never be called');
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use JMS\DiExtraBundle\Annotation as DI;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
|
||||
/**
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
abstract class RegisterController
|
||||
{
|
||||
/**
|
||||
* @Route("/register")
|
||||
*/
|
||||
public function registerAction()
|
||||
{
|
||||
$mailer = $this->getMailer();
|
||||
|
||||
return new Response($mailer->getFromMail(), 200, array('Content-Type' => 'text/plain'));
|
||||
}
|
||||
|
||||
/** @DI\LookupMethod("test_mailer") */
|
||||
abstract protected function getMailer();
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Controller;
|
||||
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use JMS\SecurityExtraBundle\Annotation\Secure;
|
||||
use JMS\DiExtraBundle\Annotation as DI;
|
||||
|
||||
/**
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
abstract class SecuredController
|
||||
{
|
||||
/**
|
||||
* @Route("/lookup-method-and-aop")
|
||||
* @Secure("ROLE_FOO")
|
||||
*/
|
||||
public function secureAction()
|
||||
{
|
||||
throw new \Exception('Should never be called');
|
||||
}
|
||||
|
||||
/** @DI\LookupMethod */
|
||||
abstract protected function getTestMailer();
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Inheritance;
|
||||
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use JMS\DiExtraBundle\Annotation as DI;
|
||||
|
||||
/**
|
||||
* @DI\Service("abstract_class")
|
||||
*
|
||||
* @author johannes
|
||||
*/
|
||||
abstract class AbstractClass
|
||||
{
|
||||
private $templating;
|
||||
|
||||
/**
|
||||
* @DI\InjectParams
|
||||
*
|
||||
* @param EngineInterface $templating
|
||||
*/
|
||||
public function setTemplating(EngineInterface $templating)
|
||||
{
|
||||
$this->templating = $templating;
|
||||
}
|
||||
|
||||
public function getTemplating()
|
||||
{
|
||||
return $this->templating;
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Inheritance;
|
||||
|
||||
use JMS\DiExtraBundle\Annotation as DI;
|
||||
|
||||
/**
|
||||
* @DI\Service("concrete_class")
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ConcreteClass extends AbstractClass
|
||||
{
|
||||
private $foo;
|
||||
private $bar;
|
||||
|
||||
/**
|
||||
* @DI\InjectParams
|
||||
*
|
||||
* @param stdClass $foo
|
||||
* @param stdClass $bar
|
||||
*/
|
||||
public function __construct($foo, $bar)
|
||||
{
|
||||
$this->foo = $foo;
|
||||
$this->bar = $bar;
|
||||
}
|
||||
|
||||
public function getFoo()
|
||||
{
|
||||
return $this->foo;
|
||||
}
|
||||
|
||||
public function getBar()
|
||||
{
|
||||
return $this->bar;
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class JMSDiExtraTestBundle extends Bundle
|
||||
{
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Mailer;
|
||||
|
||||
use JMS\DiExtraBundle\Annotation as DI;
|
||||
|
||||
/**
|
||||
* @DI\Service("test_mailer")
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class TestMailer
|
||||
{
|
||||
public function getFromMail()
|
||||
{
|
||||
return 'foo@bar.de';
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace JMS\DiExtraBundle\Tests\Functional;
|
||||
|
||||
class ControllerResolverTest extends BaseTestCase
|
||||
{
|
||||
public function testLookupMethodIsCorrectlyImplemented()
|
||||
{
|
||||
$client = $this->createClient();
|
||||
$client->request('GET', '/register');
|
||||
|
||||
$this->assertEquals('foo@bar.de', $client->getResponse()->getContent());
|
||||
}
|
||||
|
||||
public function testLookupMethodAndAopProxy()
|
||||
{
|
||||
$client = $this->createClient();
|
||||
$client->request('GET', '/lookup-method-and-aop');
|
||||
|
||||
$this->assertTrue($client->getResponse()->isRedirect('http://localhost/login'), substr((string) $client->getResponse(), 0, 512));
|
||||
|
||||
$client->insulate();
|
||||
$client->request('GET', '/lookup-method-and-aop');
|
||||
$this->assertTrue($client->getResponse()->isRedirect('http://localhost/login'), substr((string) $client->getResponse(), 0, 512));
|
||||
}
|
||||
|
||||
public function testAopProxyWhenNoDiMetadata()
|
||||
{
|
||||
$client = $this->createClient();
|
||||
$client->request('GET', '/secure-action');
|
||||
|
||||
$this->assertTrue($client->getResponse()->isRedirect('http://localhost/login'));
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace JMS\DiExtraBundle\Tests\Functional;
|
||||
|
||||
class Issue11Test extends BaseTestCase
|
||||
{
|
||||
public function testConstructorInjectionWithInheritance()
|
||||
{
|
||||
$this->createClient();
|
||||
|
||||
$container = self::$kernel->getContainer();
|
||||
$foo = $container->get('foo');
|
||||
$bar = $container->get('bar');
|
||||
$templating = $container->get('templating');
|
||||
|
||||
$concreteService = $container->get('concrete_class');
|
||||
$this->assertSame($templating, $concreteService->getTemplating());
|
||||
$this->assertSame($foo, $concreteService->getFoo());
|
||||
$this->assertSame($bar, $concreteService->getBar());
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
imports:
|
||||
- { resource: framework.yml }
|
||||
- { resource: twig.yml }
|
||||
- { resource: security.yml }
|
||||
|
||||
jms_di_extra:
|
||||
locations:
|
||||
bundles: [JMSDiExtraTestBundle]
|
||||
|
||||
services:
|
||||
foo: { class: stdClass }
|
||||
bar: { class: stdClass }
|
@@ -0,0 +1,16 @@
|
||||
framework:
|
||||
secret: test
|
||||
test: ~
|
||||
session:
|
||||
storage_id: session.storage.filesystem
|
||||
form: true
|
||||
csrf_protection: true
|
||||
validation:
|
||||
enabled: true
|
||||
enable_annotations: true
|
||||
router:
|
||||
resource: %kernel.root_dir%/config/routing.yml
|
||||
|
||||
services:
|
||||
logger:
|
||||
class: Symfony\Component\HttpKernel\Log\NullLogger
|
@@ -0,0 +1,3 @@
|
||||
TestBundle:
|
||||
type: annotation
|
||||
resource: @JMSDiExtraTestBundle/Controller/
|
@@ -0,0 +1,13 @@
|
||||
security:
|
||||
providers:
|
||||
in_memory:
|
||||
users:
|
||||
johannes: { password: login }
|
||||
|
||||
encoders:
|
||||
Symfony\Component\Security\Core\User\UserInterface: plaintext
|
||||
|
||||
firewalls:
|
||||
default:
|
||||
form_login: ~
|
||||
anonymous: ~
|
@@ -0,0 +1,7 @@
|
||||
framework:
|
||||
templating:
|
||||
engines: [twig, php]
|
||||
|
||||
twig:
|
||||
debug: %kernel.debug%
|
||||
strict_variables: %kernel.debug%
|
Reference in New Issue
Block a user