Skip to content
Snippets Groups Projects
Select Git revision
  • 579ff79680b465ecb8084a2fcbe6106e9c33f89c
  • master default protected
  • b24
  • ll-workflow
  • alc-scindage-donnees-pj
  • FJ_LL_Tbl_Contrat
  • alc-docker-node
  • ll-apiplatform
  • php84
  • ll-rgpd
  • b23
  • alc-filtre-type-intervenant
  • ll-sans-mdb5
  • formules-ancienne-infra
  • ll-formules
  • alc-intervenant-dmep
  • ll-suppr-v_vol-s
  • b20
  • ll-postgresql
  • b23.0.1
  • b22
  • 24.8
  • 24.7
  • 24.6
  • 24.5
  • 24.4
  • 24.3
  • 24.2
  • 24.1
  • 24.0
  • 23.15
  • 24.0-beta19
  • 24.0-beta18
  • 24.0-beta17
  • 24.0-beta16
  • 24.0-beta15
  • 24.0-beta14
  • 24.0-beta13
  • 23.14
  • 24.0-beta12
  • 24.0-beta11
41 results

08.0.sql

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    AbstractBddProtocoleTestCase.php 2.47 KiB
    <?php declare(strict_types=1);
    
    abstract class AbstractBddProtocoleTestCase extends AbstractBddTestCase
    {
        protected array $protocole = [];
    
    
    
        protected function setUp(): void
        {
            parent::setUp();
            $this->protocole = require(__DIR__ . '/protocole/' . $this->bddName . '.php');
        }
    
    
    
        protected function test(array $action)
        {
            $manager = $this->bdd->manager($action['manager']);
    
            try {
                $result = call_user_func_array([$manager, $action['method']], $action['args'] ?? []);
    
                $tested = false;
                if (isset($action['test-exists'])) {
                    $exists = call_user_func_array([$manager, 'exists'], [$action['test-exists']]);
                    $this->assertTrue($exists);
                    $tested = true;
                }
                if (isset($action['test-not-exists'])) {
                    $exists = call_user_func_array([$manager, 'exists'], [$action['test-not-exists']]);
                    $this->assertFalse($exists);
                    $tested = true;
                }
                if (isset($action['expected'])) {
                    $action['expected'] = $this->normalizeExpected($action['expected']);
                    if (is_array($action['expected'])) {
                        $this->assertArrayEquals($action['expected'], $result);
                    } else {
                        $this->assertEquals($action['expected'], $result);
                    }
                }
                if (!$tested) {
                    $this->assertTrue(true);
                }
            } catch (\Exception $e) {
                echo "\n" . $this->bddName . ' ' . $action['manager'] . '->' . $action['method'] . ' : ' . $e->getMessage()."\n";
                echo $e->getFile().' line '.$e->getLine()."\n";
                foreach( $e->getTrace() as $t){
                    if (str_contains($t['file'], '/bddadmin/')){
                        echo $t['file'] . ' line ' . $t['line'] . "\n";
                    }
                }
                $this->assertTrue(false);
            }
        }
    
    
    
        protected function normalizeExpected(array $expected): array
        {
    
            $res = [];
            foreach( $expected as $k => $v ){
                if (is_int($k) && is_string($v)){
                    $res[$k] = $this->bdd->normalizeObjectName($v);
                }elseif(is_string($k)){
                   $res[$this->bdd->normalizeObjectName($k)] = $v;
                }
            }
            return $res;
        }
    
    
    
        public function testProtocole()
        {
            foreach ($this->protocole as $action) {
                $this->test($action);
            }
        }
    }