1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Knp\RadBundle\AppBundle; |
4
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
6
|
|
|
use Prophecy\Argument; |
7
|
|
|
use Symfony\Component\HttpKernel\KernelInterface; |
8
|
|
|
use Symfony\Component\HttpKernel\Bundle\BundleInterface; |
9
|
|
|
use Knp\RadBundle\Reflection\ReflectionFactory; |
10
|
|
|
|
11
|
|
|
class BundleGuesserSpec extends ObjectBehavior |
12
|
|
|
{ |
13
|
|
|
function let(KernelInterface $kernel, ReflectionFactory $reflectionFactory) |
14
|
|
|
{ |
15
|
|
|
$this->beConstructedWith($kernel, $reflectionFactory, array('App', 'TestBundle')); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
function its_getBundle_gets_a_bundle_instance_given_a_className(BundleInterface $bundle, $kernel, $reflectionFactory, \ReflectionClass $refl) |
|
|
|
|
19
|
|
|
{ |
20
|
|
|
$refl->getParentClass()->willReturn(null); |
21
|
|
|
$refl->getNamespaceName()->willReturn('Vendor\Bundle\TestBundle\Controller'); |
22
|
|
|
$bundle->getName()->willReturn('TestBundle'); |
23
|
|
|
$bundle->getNamespace()->willReturn('Vendor\Bundle\TestBundle'); |
24
|
|
|
$kernel->getBundles()->willReturn(array($bundle)); |
25
|
|
|
$reflectionFactory->createReflectionClass(Argument::any())->willReturn($refl); |
26
|
|
|
$this->getBundleForClass('Vendor\Bundle\TestBundle\Controller\TestController')->shouldReturn($bundle); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
function its_getBundle_gets_the_default_app_bundle(BundleInterface $bundle, $kernel, $reflectionFactory, \ReflectionClass $refl) |
|
|
|
|
30
|
|
|
{ |
31
|
|
|
$refl->getParentClass()->willReturn(null); |
32
|
|
|
$refl->getNamespaceName()->willReturn('App\Controller'); |
33
|
|
|
$bundle->getName()->willReturn('App'); |
34
|
|
|
$bundle->getNamespace()->willReturn('App'); |
35
|
|
|
$kernel->getBundles()->willReturn(array($bundle)); |
36
|
|
|
$reflectionFactory->createReflectionClass(Argument::any())->willReturn($refl); |
37
|
|
|
$this->getBundleForClass('App\Controller\TestController')->shouldReturn($bundle); |
38
|
|
|
} |
39
|
|
|
} |
40
|
|
|
|