Commit 2ba51f2f authored by Stéphane Bouvry's avatar Stéphane Bouvry
Browse files

Fix : test unitaire pour l'extraction des périodes

parent a6c5caaa
Loading
Loading
Loading
Loading
+15
Changes for module/Oscar/src/Oscar/Service/ConfigurationAwareInterface.php: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php
/**
 * Created by PhpStorm.
 * User: bouvry
 * Date: 09/11/18
 * Time: 10:03
 */

namespace Oscar\Service;


class ConfigurationAwareInterface
{

}
 No newline at end of file
+15
Changes for module/Oscar/src/Oscar/Service/ConfigurationAwareTrait.php: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php
/**
 * Created by PhpStorm.
 * User: bouvry
 * Date: 09/11/18
 * Time: 10:05
 */

namespace Oscar\Service;


class ConfigurationAwareTrait
{

}
 No newline at end of file
+15
Changes for module/Oscar/src/Oscar/Service/UserParametersService.php: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php
/**
 * Created by PhpStorm.
 * User: bouvry
 * Date: 09/11/18
 * Time: 09:53
 */

namespace Oscar\Service;


class UserParametersService
{

}
 No newline at end of file
+15
Changes for module/Oscar/src/Oscar/Utils/ValidationInput.php: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php
/**
 * Created by PhpStorm.
 * User: bouvry
 * Date: 09/11/18
 * Time: 12:44
 */

namespace Oscar\Utils;


class ValidationInput
{

}
 No newline at end of file
+8 −6
Changes for tests/Oscar/Utils/DateTimeUtilsTest.php: 8 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -17,19 +17,21 @@ class DateTimeUtilsTest extends TestCase


        $valid = [
            ['date' => '2018-01', 'month' => 1, 'year' => 2018 ],
            ['date' => '2018-1', 'month' => 1, 'year' => 2018 ],
            ['date' => '2018-02', 'month' => 2, 'year' => 2018 ],
            ['date' => '2018-2', 'month' => 2, 'year' => 2018 ],
            ['date' => '2018-12', 'month' => 12, 'year' => 2018 ],
            ['date' => '2018-01', 'month' => 1, 'year' => 2018, 'period' => '2018-1', 'periodCode' => '2018-01' ],
            ['date' => '2018-1', 'month' => 1, 'year' => 2018, 'period' => '2018-1', 'periodCode' => '2018-01' ],
            ['date' => '2018-02', 'month' => 2, 'year' => 2018, 'period' => '2018-2', 'periodCode' => '2018-02' ],
            ['date' => '2018-2', 'month' => 2, 'year' => 2018, 'period' => '2018-2', 'periodCode' => '2018-02' ],
            ['date' => '2018-12', 'month' => 12, 'year' => 2018, 'period' => '2018-12', 'periodCode' => '2018-12' ],
        ];

        foreach ($valid as $dt){
            $result = DateTimeUtils::extractPeriodDatasFromString($dt['date']);
            
            $this->assertEquals(3, count($result));
            $this->assertEquals(4, count($result));
            $this->assertEquals($dt['month'], $result['month'], 'Le mois extrait ne correspond pas pour ' . $dt['date']);
            $this->assertEquals($dt['year'], $result['year'], 'Année extrait ne correspond pas pour ' . $dt['date']);
            $this->assertEquals($dt['period'], $result['period'], 'Année extrait ne correspond pas pour ' . $dt['date']);
            $this->assertEquals($dt['periodCode'], $result['periodCode'], 'Année extrait ne correspond pas pour ' . $dt['date']);
        }
    }