|
1
|
|
|
<?php |
|
2
|
|
|
/* Copyright (C) 2018 Michael Giesler |
|
3
|
|
|
* |
|
4
|
|
|
* This file is part of Dembelo. |
|
5
|
|
|
* |
|
6
|
|
|
* Dembelo is free software: you can redistribute it and/or modify |
|
7
|
|
|
* it under the terms of the GNU Affero General Public License as published by |
|
8
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
9
|
|
|
* (at your option) any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* Dembelo is distributed in the hope that it will be useful, |
|
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14
|
|
|
* GNU Affero General Public License 3 for more details. |
|
15
|
|
|
* |
|
16
|
|
|
* You should have received a copy of the GNU Affero General Public License 3 |
|
17
|
|
|
* along with Dembelo. If not, see <http://www.gnu.org/licenses/>. |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
namespace AdminBundle\IntegrationTests\Controller; |
|
21
|
|
|
|
|
22
|
|
|
use DembeloMain\Document\Licensee; |
|
23
|
|
|
use DembeloMain\Document\Textnode; |
|
24
|
|
|
use DembeloMain\IntegrationTests\WebTestCase; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @group integration |
|
28
|
|
|
*/ |
|
29
|
|
|
class TextnodeControllerTest extends WebTestCase |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* @return void |
|
33
|
|
|
*/ |
|
34
|
|
|
public function testTextnodesActionForZeroTextnodes(): void |
|
35
|
|
|
{ |
|
36
|
|
|
$client = static::createClient(); |
|
37
|
|
|
$client->request('POST', '/admin/textnodes'); |
|
38
|
|
|
$response = $client->getResponse(); |
|
39
|
|
|
self::assertNotNull($response); |
|
40
|
|
|
self::assertEquals(200, $response->getStatusCode()); |
|
41
|
|
|
self::assertJsonStringEqualsJsonString('[]', $response->getContent()); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @return void |
|
46
|
|
|
*/ |
|
47
|
|
|
public function testTextnodesActionForMultipleTextnodes(): void |
|
48
|
|
|
{ |
|
49
|
|
|
$licensee = new Licensee(); |
|
50
|
|
|
$licensee->setName('some Licensee'); |
|
51
|
|
|
$this->getMongo()->persist($licensee); |
|
52
|
|
|
$this->getMongo()->flush(); |
|
53
|
|
|
|
|
54
|
|
|
$textnode1 = new Textnode(); |
|
55
|
|
|
$textnode1->setCreated(new \DateTime()); |
|
|
|
|
|
|
56
|
|
|
$textnode1->setStatus(Textnode::STATUS_ACTIVE); |
|
57
|
|
|
$textnode1->setLicenseeId($licensee->getId()); |
|
58
|
|
|
$this->getMongo()->persist($textnode1); |
|
59
|
|
|
|
|
60
|
|
|
$textnode2 = new Textnode(); |
|
61
|
|
|
$textnode2->setCreated(new \DateTime()); |
|
62
|
|
|
$textnode2->setStatus(Textnode::STATUS_INACTIVE); |
|
63
|
|
|
$textnode2->setLicenseeId($licensee->getId()); |
|
64
|
|
|
$this->getMongo()->persist($textnode2); |
|
65
|
|
|
|
|
66
|
|
|
$this->getMongo()->flush(); |
|
67
|
|
|
|
|
68
|
|
|
$client = static::createClient(); |
|
69
|
|
|
$client->request('POST', '/admin/textnodes'); |
|
70
|
|
|
$response = $client->getResponse(); |
|
71
|
|
|
self::assertNotNull($response); |
|
72
|
|
|
self::assertEquals(200, $response->getStatusCode(), $response->getContent()); |
|
73
|
|
|
self::assertJson($response->getContent()); |
|
74
|
|
|
$decoded = json_decode($response->getContent()); |
|
75
|
|
|
self::assertInternalType('array', $decoded); |
|
76
|
|
|
self::assertCount(2, $decoded); |
|
77
|
|
|
self::assertInstanceOf(\stdClass::class, $decoded[0]); |
|
78
|
|
|
self::assertEquals('some Licensee', $decoded[0]->licensee); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|