|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace DDTrace\Tests\Integrations\Symfony\V5_2; |
| 4 | + |
| 5 | +use DDTrace\Tests\Common\WebFrameworkTestCase; |
| 6 | +use DDTrace\Tests\Frameworks\Util\Request\PostSpec; |
| 7 | +use DDTrace\Tests\Frameworks\Util\Request\GetSpec; |
| 8 | +use datadog\appsec\AppsecStatus; |
| 9 | + |
| 10 | +class PathParamsTest extends WebFrameworkTestCase |
| 11 | +{ |
| 12 | + protected static function getAppIndexScript() |
| 13 | + { |
| 14 | + return __DIR__ . '/../../../Frameworks/Symfony/Version_5_2/public/index.php'; |
| 15 | + } |
| 16 | + |
| 17 | + protected function connection() |
| 18 | + { |
| 19 | + return new \PDO('mysql:host=mysql_integration;dbname=test', 'test', 'test'); |
| 20 | + } |
| 21 | + |
| 22 | + protected function ddSetUp() |
| 23 | + { |
| 24 | + parent::ddSetUp(); |
| 25 | + AppsecStatus::getInstance()->setDefaults(); |
| 26 | + } |
| 27 | + |
| 28 | + public static function ddSetUpBeforeClass() |
| 29 | + { |
| 30 | + parent::ddSetUpBeforeClass(); |
| 31 | + AppsecStatus::getInstance()->init(); |
| 32 | + } |
| 33 | + |
| 34 | + public static function ddTearDownAfterClass() |
| 35 | + { |
| 36 | + AppsecStatus::getInstance()->destroy(); |
| 37 | + parent::ddTearDownAfterClass(); |
| 38 | + } |
| 39 | + |
| 40 | + public function testDynamicRouteWithOptionalsFilled() |
| 41 | + { |
| 42 | + $param01 = 'first_param'; |
| 43 | + $param02 = 'second_param'; |
| 44 | + $this->call(GetSpec::create('dynamic', "/dynamic_route/$param01/$param02")); |
| 45 | + $events = AppsecStatus::getInstance()->getEvents(); |
| 46 | + $this->assertEquals(1, count($events)); |
| 47 | + $this->assertEquals($param01, $events[0]['param01']); |
| 48 | + $this->assertEquals($param02, $events[0]['param02']); |
| 49 | + $this->assertEquals('ddappsec_push_address', $events[0]['eventName']); |
| 50 | + } |
| 51 | + |
| 52 | + public function testDynamicRouteWithOptionalsNotFilled() |
| 53 | + { |
| 54 | + $param01 = 'first_param'; |
| 55 | + $this->call(GetSpec::create('dynamic', "/dynamic_route/$param01")); |
| 56 | + $events = AppsecStatus::getInstance()->getEvents(); |
| 57 | + $this->assertEquals(1, count($events)); |
| 58 | + $this->assertEquals($param01, $events[0]['param01']); |
| 59 | + $this->assertEmpty($events[0]['param02']); |
| 60 | + $this->assertEquals('ddappsec_push_address', $events[0]['eventName']); |
| 61 | + } |
| 62 | + |
| 63 | + |
| 64 | + public function testStaticRoute() |
| 65 | + { |
| 66 | + $this->call(GetSpec::create('static', "/simple")); |
| 67 | + $events = AppsecStatus::getInstance()->getEvents(); |
| 68 | + $this->assertEquals(0, count($events)); |
| 69 | + } |
| 70 | +} |
0 commit comments