Skip to content

Commit

Permalink
phalcon#14928 - Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Aziz Muzafarov committed Nov 7, 2021
1 parent d154331 commit b6e18da
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
8 changes: 7 additions & 1 deletion phalcon/Validation/Validator/File.zep
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ use Phalcon\Validation\Validator\File\Size\Min as MinFileSize;
* "messageType" => "Allowed file types are :types",
* "maxResolution" => "800x600",
* "messageMaxResolution" => "Max resolution of :field is :resolution",
* "messageFileEmpty" => "File is empty",
* "messageIniSize" => "Ini size is not valid",
* "messageValid" => "File is not valid",
* ]
* )
* );
Expand Down Expand Up @@ -113,7 +116,10 @@ class File extends AbstractValidatorComposite
* 'messageMinResolution' => '',
* 'equalResolution' => '1000x1000',
* 'messageEqualResolution' => '',
* 'allowEmpty' => false
* 'allowEmpty' => false,
* 'messageFileEmpty' => '',
* 'messageIniSize' => '',
* 'messageValid' => ''
* ]
*/
public function __construct(array! options = [])
Expand Down
57 changes: 57 additions & 0 deletions tests/integration/Validation/Validator/File/CustomMessagesCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

/**
* This file is part of the Phalcon Framework.
*
* (c) Phalcon Team <team@phalcon.io>
*
* For the full copyright and license information, please view the LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Phalcon\Tests\Integration\Validation\Validator\File;

use IntegrationTester;
use Phalcon\Tests\Fixtures\Traits\ValidationTrait;
use Phalcon\Validation\Validator\File;

/**
* Class CustomMessagesCest
*/
class CustomMessagesCest
{
use ValidationTrait;

/**
* Tests Phalcon\Validation\Validator\File :: customMessages[]
*
* @author Phalcon Team <team@phalcon.io>
* @since 2018-11-13
*/
public function validationValidatorFileCustomMessages(IntegrationTester $I)
{
$I->wantToTest('Validation\Validator\File - customMessages[]');

$options = [
'maxSize' => '0.5M',
'messageFileEmpty' => 'File is empty',
'messageIniSize' => 'Ini size is not valid',
'messageValid' => 'File is not valid',
];
$file = new File($options);
$validators = $file->getValidators();

/** @var File\AbstractFile $validator */
foreach ($validators as $validator) {
$messageFileEmpty = $validator->getMessageFileEmpty();
$messageIniSize = $validator->getMessageIniSize();
$messageValid = $validator->getMessageValid();

$I->assertEquals($options['messageFileEmpty'], $messageFileEmpty);
$I->assertEquals($options['messageIniSize'], $messageIniSize);
$I->assertEquals($options['messageValid'], $messageValid);
}
}
}

0 comments on commit b6e18da

Please sign in to comment.