Skip to content

Commit

Permalink
Tidied up tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
SidRoberts authored and niden committed May 14, 2019
1 parent aa5b3ff commit a5a172e
Show file tree
Hide file tree
Showing 2,602 changed files with 3,133 additions and 7,723 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -57,3 +57,5 @@ php_test_results_*.txt
docker-compose.yml
build/gccarch
tests/_cache

.php_cs.cache
53 changes: 53 additions & 0 deletions .php_cs.dist
@@ -0,0 +1,53 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in('tests/')
->exclude('syntax/volt/');

return PhpCsFixer\Config::create()
->setRules(
[
'array_syntax' => ['syntax' => 'short'],
'align_multiline_comment' => true,
'blank_line_before_statement' => true,
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'dir_constant' => true,
'elseif' => true,
'fully_qualified_strict_types' => true,
'include' => true,
'lowercase_constants' => true,
'lowercase_keywords' => true,
'new_with_braces' => true,
'no_blank_lines_after_class_opening' => true,
'no_closing_tag' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_superfluous_phpdoc_tags' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unused_imports' => true,
'object_operator_without_whitespace' => true,
'ordered_imports' => true,
'php_unit_strict' => true,
'phpdoc_no_access' => true,
'phpdoc_no_package' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_scalar' => true,
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_var_without_name' => true,
'single_blank_line_at_eof' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_quote' => true,
'standardize_not_equals' => true,
'standardize_increment' => true,
'strict_param' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline_array' => true,
'visibility_required' => true,
]
)
->setFinder($finder);
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -48,6 +48,7 @@
"ext-psr": "0.6.0",
"ext-xml": "*",
"codeception/codeception": "^2.5",
"friendsofphp/php-cs-fixer": "~2.0",
"mustache/mustache": "^2.12",
"predis/predis": "^1.1",
"squizlabs/php_codesniffer": "^3.4",
Expand Down
2 changes: 1 addition & 1 deletion tests/_bootstrap.php
Expand Up @@ -17,7 +17,7 @@

clearstatcache();

$root = dirname(realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
$root = dirname(realpath(__DIR__) . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
/**
* Setting this in the $_ENV so that DotLoad sets everything up properly
*/
Expand Down
11 changes: 10 additions & 1 deletion tests/_ci/generate-test-stubs.php
Expand Up @@ -61,7 +61,7 @@ public function %nn%%m%(UnitTester $I)
'%d%' => date('Y-m-d'),
];

$outputDir = dirname(dirname(__FILE__)) . '/nikos/';
$outputDir = dirname(__DIR__) . '/nikos/';

foreach ($phalconClasses as $class) {
$newClass = str_replace('Phalcon\\', '', $class);
Expand All @@ -79,30 +79,39 @@ public function %nn%%m%(UnitTester $I)
switch ($method) {
case '__construct':
$method = 'construct';

break;
case '__destruct':
$method = 'destruct';

break;
case '__toString':
$method = 'toString';

break;
case '__get':
$method = 'underscoreGet';

break;
case '__set':
$method = 'underscoreSet';

break;
case '__isset':
$method = 'underscoreIsSet';

break;
case '__unset':
$method = 'underscoreUnset';

break;
case '__wakeup':
$method = 'wakeup';

break;
case '__set_state':
$method = 'setState';

break;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/_config/bootstrap.php
Expand Up @@ -16,7 +16,7 @@
/**
* Load environment
*/
$root = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR;
$root = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR;

loadEnvironment($root);

Expand Down
28 changes: 14 additions & 14 deletions tests/_data/assets/config/config.php
@@ -1,23 +1,23 @@
<?php

return [
"phalcon" => [
"baseuri" => "/phalcon/",
'phalcon' => [
'baseuri' => '/phalcon/',
],
"models" => [
"metadata" => "memory",
'models' => [
'metadata' => 'memory',
],
"database" => [
"adapter" => "mysql",
"host" => "localhost",
"username" => "user",
"password" => "passwd",
"name" => "demo",
'database' => [
'adapter' => 'mysql',
'host' => 'localhost',
'username' => 'user',
'password' => 'passwd',
'name' => 'demo',
],
"test" => [
"parent" => [
"property" => 1,
"property2" => "yeah",
'test' => [
'parent' => [
'property' => 1,
'property2' => 'yeah',
],
],
'issue-12725' => [
Expand Down
3 changes: 0 additions & 3 deletions tests/_data/fixtures/Acl/TestComponentAware.php
Expand Up @@ -47,9 +47,6 @@ public function getUser()
return $this->user;
}

/**
* @return string
*/
public function getComponentName(): string
{
return $this->resourceName;
Expand Down
3 changes: 0 additions & 3 deletions tests/_data/fixtures/Acl/TestRoleAware.php
Expand Up @@ -47,9 +47,6 @@ public function getId()
return $this->id;
}

/**
* @return string
*/
public function getRoleName(): string
{
return $this->roleName;
Expand Down
6 changes: 0 additions & 6 deletions tests/_data/fixtures/Acl/TestRoleComponentAware.php
Expand Up @@ -47,17 +47,11 @@ public function __construct($user, $componentName, $roleName)
$this->roleName = $roleName;
}

/**
* @return string
*/
public function getComponentName(): string
{
return $this->componentName;
}

/**
* @return string
*/
public function getRoleName(): string
{
return $this->roleName;
Expand Down
6 changes: 1 addition & 5 deletions tests/_data/fixtures/Assets/TrimFilter.php
Expand Up @@ -20,18 +20,14 @@ class TrimFilter implements FilterInterface
*
* @author Nikolaos Dimopoulos <nikos@phalconphp.com>
* @since 2014-10-05
*
* @param string $content
*
* @return string
*/
public function filter(string $content): string
{
return str_replace(
[
"\n",
"\r",
" ",
' ',
"\t",
],
'',
Expand Down
4 changes: 0 additions & 4 deletions tests/_data/fixtures/Assets/UppercaseFilter.php
Expand Up @@ -20,10 +20,6 @@ class UppercaseFilter implements FilterInterface
*
* @author Nikolaos Dimopoulos <nikos@phalconphp.com>
* @since 2014-10-05
*
* @param string $content
*
* @return string
*/
public function filter(string $content): string
{
Expand Down
3 changes: 0 additions & 3 deletions tests/_data/fixtures/Cache/Adapter/Libmemcached.php
Expand Up @@ -21,9 +21,6 @@
*/
class Libmemcached extends CacheLibmemcached
{
/**
* @return array
*/
public function getOptions(): array
{
return $this->options;
Expand Down
2 changes: 1 addition & 1 deletion tests/_data/fixtures/Di/SomeServiceProvider.php
Expand Up @@ -14,8 +14,8 @@
+------------------------------------------------------------------------+
*/

use Phalcon\DiInterface;
use Phalcon\Di\ServiceProviderInterface;
use Phalcon\DiInterface;

class SomeServiceProvider implements ServiceProviderInterface
{
Expand Down
2 changes: 1 addition & 1 deletion tests/_data/fixtures/Di/services.php
Expand Up @@ -14,7 +14,7 @@
[
'type' => 'service',
'name' => 'config',
]
],
],
],
];
5 changes: 0 additions & 5 deletions tests/_data/fixtures/Filter/Sanitize/IPv4.php
Expand Up @@ -12,18 +12,13 @@

namespace Phalcon\Test\Fixtures\Filter\Sanitize;


/**
* Class IPv4
*/
class IPv4
{
/**
* Sanitizes IP addresses
*
* @param mixed $ip
*
* @return mixed
*/
public function __invoke($ip)
{
Expand Down
1 change: 0 additions & 1 deletion tests/_data/fixtures/Helpers/TagHelper.php
Expand Up @@ -11,7 +11,6 @@

namespace Phalcon\Test\Fixtures\Helpers;

use Phalcon\Tag;
use UnitTester;

class TagHelper extends TagSetup
Expand Down
30 changes: 9 additions & 21 deletions tests/_data/fixtures/Helpers/TagSetup.php
Expand Up @@ -21,9 +21,6 @@ class TagSetup

protected $doctype = Tag::HTML5;

/**
* @param UnitTester $I
*/
public function _before(UnitTester $I)
{
$this->newDi();
Expand All @@ -43,8 +40,6 @@ public function _before(UnitTester $I)
* @author Phalcon Team <team@phalconphp.com>
* @since 2014-09-04
*
* @param $doctype
*
* @return string
*/
protected function docTypeStringToConstant(string $doctype)
Expand Down Expand Up @@ -122,9 +117,6 @@ protected function docTypeStringToConstant(string $doctype)
}
}

/**
* @param UnitTester $I
*/
public function _after(UnitTester $I)
{
Tag::setDocType($this->doctype);
Expand All @@ -134,9 +126,6 @@ public function _after(UnitTester $I)

/**
* Runs a doctype test, one for each doctype
*
* @param UnitTester $I
* @param int $doctype
*/
protected function runDoctypeTest(UnitTester $I, int $doctype)
{
Expand All @@ -145,8 +134,11 @@ protected function runDoctypeTest(UnitTester $I, int $doctype)
Tag::setDocType($doctype);

$expected = $this->docTypeToString($doctype);
$actual = Tag::getDocType();
$I->assertEquals($expected, $actual);

$I->assertEquals(
$expected,
Tag::getDocType()
);
}

/**
Expand All @@ -155,8 +147,6 @@ protected function runDoctypeTest(UnitTester $I, int $doctype)
* @author Phalcon Team <team@phalconphp.com>
* @since 2014-09-04
*
* @param int $doctype
*
* @return string
*/
protected function docTypeToString(int $doctype)
Expand Down Expand Up @@ -220,12 +210,10 @@ protected function docTypeToString(int $doctype)
/**
* Runs the test for a Tag::$function with $options
*
* @param \UnitTester $I
* @param string $function
* @param mixed $options
* @param string $expected
* @param boolean $xhtml
* @param string $set
* @param string $function
* @param string $expected
* @param bool $xhtml
* @param string $set
*/
protected function testFieldParameter(UnitTester $I, $function, $options, $expected, $xhtml = false, $set = '')
{
Expand Down

0 comments on commit a5a172e

Please sign in to comment.