|
|
@@ -1239,4 +1239,61 @@ class ElementControllerTest extends FunctionalTest
|
|
1239
|
1239
|
|
|
1240
|
1240
|
}
|
|
1241
|
1241
|
|
|
|
1242
|
+ public function testAddElementNeedTags()
|
|
|
1243
|
+ {
|
|
|
1244
|
+ $this->client = self::createClient();
|
|
|
1245
|
+ $this->connectUser('joelle', 'toor');
|
|
|
1246
|
+
|
|
|
1247
|
+ $joelle = $this->getUser();
|
|
|
1248
|
+
|
|
|
1249
|
+ $hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
|
|
|
1250
|
+ $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
|
|
|
1251
|
+
|
|
|
1252
|
+ // L'élément n'existe pas encore
|
|
|
1253
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
|
1254
|
+ ->findOneByName('Musique qui dechire bis4d5456aqd')
|
|
|
1255
|
+ ;
|
|
|
1256
|
+ $this->assertTrue(is_null($element));
|
|
|
1257
|
+
|
|
|
1258
|
+ // On commence par ajouter un tag
|
|
|
1259
|
+ $url = $this->generateUrl('element_add');
|
|
|
1260
|
+
|
|
|
1261
|
+ $extract = $this->crawler->filter('input[name="element_add[_token]"]')
|
|
|
1262
|
+ ->extract(array('value'));
|
|
|
1263
|
+ $csrf = $extract[0];
|
|
|
1264
|
+
|
|
|
1265
|
+ $crawler = $this->client->request(
|
|
|
1266
|
+ 'POST',
|
|
|
1267
|
+ $url,
|
|
|
1268
|
+ array(
|
|
|
1269
|
+ 'element_add' => array(
|
|
|
1270
|
+ '_token' => $csrf,
|
|
|
1271
|
+ 'name' => 'Musique qui dechire bis4d5456aqd',
|
|
|
1272
|
+ 'url' => 'http://www.youtube.com/watch?v=WC8qb_of04E',
|
|
|
1273
|
+ 'tags' => json_encode(array($hardtek->getId(), $tribe->getId())),
|
|
|
1274
|
+ 'need_tags' => '1'
|
|
|
1275
|
+ )
|
|
|
1276
|
+
|
|
|
1277
|
+ ),
|
|
|
1278
|
+ array(),
|
|
|
1279
|
+ array('HTTP_X-Requested-With' => 'XMLHttpRequest')
|
|
|
1280
|
+ );
|
|
|
1281
|
+
|
|
|
1282
|
+ $this->isResponseSuccess();
|
|
|
1283
|
+
|
|
|
1284
|
+ $response = json_decode($this->client->getResponse()->getContent(), true);
|
|
|
1285
|
+ $this->assertEquals($response['status'], 'success');
|
|
|
1286
|
+
|
|
|
1287
|
+
|
|
|
1288
|
+ $element_need_tags = $this->findOneBy('Element', array(
|
|
|
1289
|
+ 'name' => 'Musique qui dechire bis4d5456aqd',
|
|
|
1290
|
+ 'owner' => $joelle->getId(),
|
|
|
1291
|
+ 'need_tags' => true
|
|
|
1292
|
+ ));
|
|
|
1293
|
+
|
|
|
1294
|
+ // L'objet est bien en base
|
|
|
1295
|
+ $this->assertTrue(!is_null($element_need_tags));
|
|
|
1296
|
+
|
|
|
1297
|
+ }
|
|
|
1298
|
+
|
|
1242
|
1299
|
}
|