Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added new test cases from kPHP #46

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/Folders/Folder_011_Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace ModuliteTests\Folders;

use ModuliteTests\RunAllRulesForFolderTestCase;


class Folder_011_Test extends RunAllRulesForFolderTestCase {
static function getProjectFolderName(): string {
return '011_late_static_bindings';
}
}
12 changes: 12 additions & 0 deletions tests/Folders/Folder_012_Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace ModuliteTests\Folders;

use ModuliteTests\RunAllRulesForFolderTestCase;


class Folder_012_Test extends RunAllRulesForFolderTestCase {
static function getProjectFolderName(): string {
return '012_package_not_required_in_derived_class';
}
}
12 changes: 12 additions & 0 deletions tests/Folders/Folder_013_Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace ModuliteTests\Folders;

use ModuliteTests\RunAllRulesForFolderTestCase;


class Folder_013_Test extends RunAllRulesForFolderTestCase {
static function getProjectFolderName(): string {
return '013_inheritance_calling_class_inside_parent';
}
}
12 changes: 12 additions & 0 deletions tests/Folders/Folder_125_Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace ModuliteTests\Folders;

use ModuliteTests\RunAllRulesForFolderTestCase;


class Folder_125_Test extends RunAllRulesForFolderTestCase {
static function getProjectFolderName(): string {
return '125_wrong_static_bindings';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@ok
<?php
#ifndef KPHP
require_once 'kphp_tester_include.php';
#endif

$_ = \Messages011\MessagesLogger011::log();
\Messages011\MessagesLogger011::create();
12 changes: 12 additions & 0 deletions tests/php/011_late_static_bindings/Logs011/BaseLog011.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Logs011;

abstract class BaseLog011 {
protected static function logAction(): bool {
return true;
}

protected static function createLog(): void {
}
}
15 changes: 15 additions & 0 deletions tests/php/011_late_static_bindings/Messages011/.modulite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "@messages011"
description: ""
namespace: "Messages011\\"

export:
- "MessagesLogger011"

force-internal:

require:
- "\\Logs011\\BaseLog011"
- "\\Logs011\\BaseLog011::createLog()"
- "\\Logs011\\BaseLog011::logAction()"

allow-internal-access:
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Messages011;

use Logs011\BaseLog011;

class MessagesLogger011 extends BaseLog011 {

public static function create(): void {
parent::createLog();
}

public static function log(): bool {
return parent::logAction();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@ok
KPHP_COMPOSER_ROOT={dir}
<?php
#ifndef KPHP
require_once 'kphp_tester_include.php';
#endif

\Printer012\Printer012::print();
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace BasePrinter012;

use Vk\TestSrt\SomeStr;

class BasePrinter012 {
final public static function basePrint(): void {
$r1 = new SomeStr();
echo "BasePrint\n";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "@printer012"
description: ""
namespace: "Printer012\\"

# "Public API" of the modulite: classes, functions, constants, etc.
# Symbols not listed here will be internal.
export:
- "Printer012"

# Class members to exclude, they override "export".
force-internal:

# Dependencies: other modulites, global classes, defines, etc.
require:
- "\\BasePrinter012\\BasePrinter012"

# Granting partial access to internal symbols, "as an exception".
allow-internal-access:
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Printer012;

use BasePrinter012\BasePrinter012;

class Printer012 extends BasePrinter012 {

public static function print(): void {
self::basePrint();
echo "print\n";
}
}
18 changes: 18 additions & 0 deletions tests/php/012_package_not_required_in_derived_class/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "phpt/012",
"autoload": {
"psr-4": {
"BasePrinter012\\": "./BasePrinter012",
"Printer012\\": "./Printer012"
}
},
"require": {
"vk/strings": "*"
},
"repositories": [
{
"type": "path",
"url": "./packages/vk-strings"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "vk/strings",
"version": "0.0.1",
"type": "library",
"autoload": {
"psr-4": {
"Vk\\TestSrt\\": "src/"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Vk\TestSrt;

class SomeStr {
public static function concatStr(string $s1, string $s2): string {
return $s1 . $s2;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

// autoload.php @generated by Composer

if (PHP_VERSION_ID < 50600) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, $err);
} elseif (!headers_sent()) {
echo $err;
}
}
trigger_error(
$err,
E_USER_ERROR
);
}

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit451b6d5135cd4eb8e84df3fc66c39587::getLoader();
Loading