1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MediaMonks\SonataMediaBundle\Tests\Functional; |
4
|
|
|
|
5
|
|
|
use MediaMonks\SonataMediaBundle\ParameterBag\ImageParameterBag; |
6
|
|
|
use MediaMonks\SonataMediaBundle\Handler\SignatureParameterHandler; |
7
|
|
|
use MediaMonks\SonataMediaBundle\Model\MediaInterface; |
8
|
|
|
use Symfony\Bundle\FrameworkBundle\Client; |
9
|
|
|
use Mockery as m; |
10
|
|
|
use Symfony\Component\DomCrawler\Form; |
11
|
|
|
|
12
|
|
|
abstract class AdminTestAbstract extends AbstractBaseFunctionTest |
13
|
|
|
{ |
14
|
|
|
const BASE_PATH = '/mediamonks/sonatamedia/media/'; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var Client |
18
|
|
|
*/ |
19
|
|
|
protected $client; |
20
|
|
|
|
21
|
|
|
protected function setUp() |
22
|
|
|
{ |
23
|
|
|
parent::setUp(); |
24
|
|
|
|
25
|
|
|
$this->client = $this->getAuthenticatedClient(); |
26
|
|
|
$this->client->followRedirects(); |
27
|
|
|
|
28
|
|
|
$this->loadFixtures([]); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
protected function verifyMediaImageIsGenerated() |
32
|
|
|
{ |
33
|
|
|
$this->emptyFolder($this->getMediaPathPublic()); |
34
|
|
|
|
35
|
|
|
$media = m::mock(MediaInterface::class); |
36
|
|
|
$media->shouldReceive('getId')->andReturn(1); |
37
|
|
|
$media->shouldReceive('getFocalPoint')->andReturn('50-50'); |
38
|
|
|
|
39
|
|
|
$parameterBag = new ImageParameterBag(400, 300); |
40
|
|
|
|
41
|
|
|
$signature = new SignatureParameterHandler(self::$kernel->getContainer()->getParameter('secret')); |
42
|
|
|
$parameters = $signature->getRouteParameters($media, $parameterBag); |
43
|
|
|
|
44
|
|
|
$this->client->request( |
45
|
|
|
'GET', |
46
|
|
|
sprintf( |
47
|
|
|
'%s%d/image/%d/%d?s=%s', |
48
|
|
|
self::BASE_PATH, |
49
|
|
|
$media->getId(), |
|
|
|
|
50
|
|
|
$parameterBag->getWidth(), |
51
|
|
|
$parameterBag->getHeight(), |
52
|
|
|
$parameters['s'] |
53
|
|
|
) |
54
|
|
|
); |
55
|
|
|
|
56
|
|
|
$this->assertNumberOfFilesInPath(1, $this->getMediaPathPublic()); |
57
|
|
|
|
58
|
|
|
$parameterBag = new ImageParameterBag(800, 600); |
59
|
|
|
$signature = new SignatureParameterHandler(self::$kernel->getContainer()->getParameter('secret')); |
60
|
|
|
$parameters = $signature->getRouteParameters($media, $parameterBag); |
61
|
|
|
|
62
|
|
|
$this->client->followRedirects(false); |
63
|
|
|
$this->client->request( |
64
|
|
|
'GET', |
65
|
|
|
sprintf( |
66
|
|
|
'/media/image/%d/%d/%d?s=%s', |
67
|
|
|
$media->getId(), |
|
|
|
|
68
|
|
|
$parameterBag->getWidth(), |
69
|
|
|
$parameterBag->getHeight(), |
70
|
|
|
$parameters['s'] |
71
|
|
|
) |
72
|
|
|
); |
73
|
|
|
|
74
|
|
|
$this->assertNumberOfFilesInPath(2, $this->getMediaPathPublic()); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
protected function uploadImage() |
78
|
|
|
{ |
79
|
|
|
$provider = 'image'; |
80
|
|
|
$crawler = $this->client->request('GET', self::BASE_PATH.'create?provider='.$provider); |
81
|
|
|
$form = $crawler->selectButton('Create')->form(); |
82
|
|
|
$this->assertSonataFormValues( |
83
|
|
|
$form, |
84
|
|
|
[ |
85
|
|
|
'provider' => $provider, |
86
|
|
|
] |
87
|
|
|
); |
88
|
|
|
$this->setFormBinaryContent($form, $this->getFixturesPath().'monk.jpg'); |
89
|
|
|
return $this->client->submit($form); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.