comsave/salesforce-mapper-bundle

View on GitHub
src/LogicItLab/Salesforce/MapperBundle/WsdlValidatorTestCase.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

namespace LogicItLab\Salesforce\MapperBundle;

use LogicItLab\Salesforce\MapperBundle\Annotation\AnnotationReader;
use PHPUnit\Framework\TestCase;

abstract class WsdlValidatorTestCase extends TestCase
{
    public abstract function modelAndWsdlDataProvider(): array;

    /**
     * @param $modelsDir
     * @param $wsdlPath
     * @dataProvider modelAndWsdlDataProvider
     */
    public function testWsdlIsValid($modelsDir, $wsdlPath)
    {
        $missingFields = $this->buildValidator()->validate($modelsDir, $wsdlPath);

        $this->assertEmpty($missingFields, $this->buildValidator()->buildErrorMessage($missingFields));
    }

    private function buildValidator(): WsdlValidator
    {
        $annotationReader = new AnnotationReader(new \Doctrine\Common\Annotations\AnnotationReader());

        return new WsdlValidator($annotationReader);
    }
}