<commit_before><?php
declare(strict_types=1);

namespace Webuntis\Tests\Repositories;

use PHPUnit\Framework\TestCase;
use Webuntis\Repositories\UserRepository;
use Webuntis\Models\Holidays;
use Webuntis\Types\DateType;
use Webuntis\Handler\ExecutionHandler;
use Webuntis\Configuration\WebuntisConfiguration;
use Symfony\Component\Console\Output\Output;
use Symfony\Component\Console\Input\Input;
use Symfony\Component\Console\Helper\QuestionHelper;


final class DateTypeTest extends TestCase
{
    public function setUp() : void 
    {
        $config = new WebuntisConfiguration([ 
            'default' => [
                   //f.e. thalia, cissa etc.
                    'server' => 'yourserver',
                    'school' => 'yourschool',
                    'username' => 'yourusername',
                    'password' => '<PASSWORD>'
                ],
            'admin' => [
                   //f.e. thalia, cissa etc.
                    'server' => 'yourserver',
                    'school' => 'yourschool',
                    'username' => 'youradminusername',
                    'password' => '<PASSWORD>'
            ],
            'security_manager' => 'Webuntis\Tests\TestSecurityManager'
        ]);
    }

    public function testExecute() : void
    {   
        $repo = new UserRepository();

        $field = [
            'startDate' => [
                'type' => 'date',
                'api' => [
                    'name' => 'startDate'
                ]
            ]
        ];
        $data = [
            'startDate' => '20180704'
        ];

        $holiday = new Holidays();

        DateType::execute($holiday, $data, $field);

        $this->assertEquals(new \DateTime('20180704'), $holiday->getStartDate());
    }

    public function testGenerateTypeWithConsole() : void
    {
        $output = $this->createMock(Output::class);
        $input = $this->createMock(Input::class);
        $helper = $this->createMock(QuestionHelper::class);

        $helper->method('ask')
               ->willReturn('test');
        
        $this->assertEquals([
            'type' => 'date',
            'api' => [
                'name' => 'test'
            ]
        ], DateType::generateTypeWithConsole($output, $input, $helper));
    }

    public function testGetName() : void 
    {
        $this->assertEquals('date', DateType::getName());<commit_msg>#19 added sample model with one property to test<commit_after><?php
declare(strict_types=1);

namespace Webuntis\Tests\Types;

use PHPUnit\Framework\TestCase;
use Webuntis\Repositories\UserRepository;
use Webuntis\Models\Holidays;
use Webuntis\Models\AbstractModel;
use Webuntis\Types\DateType;
use Webuntis\Handler\ExecutionHandler;
use Webuntis\Configuration\WebuntisConfiguration;
use Symfony\Component\Console\Output\Output;
use Symfony\Component\Console\Input\Input;
use Symfony\Component\Console\Helper\QuestionHelper;


final class DateTypeTest extends TestCase
{
    public function setUp() : void 
    {
        $config = new WebuntisConfiguration([ 
            'default' => [
                   //f.e. thalia, cissa etc.
                    'server' => 'yourserver',
                    'school' => 'yourschool',
                    'username' => 'yourusername',
                    'password' => '<PASSWORD>'
                ],
            'admin' => [
                   //f.e. thalia, cissa etc.
                    'server' => 'yourserver',
                    'school' => 'yourschool',
                    'username' => 'youradminusername',
                    'password' => '<PASSWORD>'
            ],
            'security_manager' => 'Webuntis\Tests\TestSecurityManager'
        ]);
    }

    public function testExecute() : void
    {   
        $field = [
            'dateTest' => [
                'type' => 'date',
                'api' => [
                    'name' => 'testDate'
                ]
            ]
        ];
        $data = [
            'testDate' => '20180704'
        ];

        $test = new class extends AbstractModel {
            private $dateTest;

            public function set(string $field, $value) 
            {
                $this->$field = $value;
            }

            public function getDateTest() 
            {
                return $this->dateTest;
            }
        };


        DateType::execute($test, $data, $field);

        $this->assertEquals(new \DateTime('20180704'), $test->getDateTest());
    }

    public function testGenerateTypeWithConsole() : void
    {
        $output = $this->createMock(Output::class);
        $input = $this->createMock(Input::class);
        $helper = $this->createMock(QuestionHelper::class);

        $helper->method('ask')
               ->willReturn('test');
        
        $this->assertEquals([
            'type' => 'date',
            'api' => [
                'name' => 'test'
            ]
        ], DateType::generateTypeWithConsole($output, $input, $helper));
    }

    public function testGetName() : void 
    {
        $this->assertEquals('date', DateType::getName());
{'fraction_non_alphanumeric': 0.1364082433758587, 'fraction_numerical': 0.0070657507360157015, 'mean_word_length': 1.728051391862955, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7193939', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1363, 'n_words': 252}