Moved all old tests to another folder
This commit is contained in:
parent
960770d73f
commit
2ad6dfabab
15 changed files with 8 additions and 8 deletions
103
tests/old_tests/composer/json_example.json
Normal file
103
tests/old_tests/composer/json_example.json
Normal file
|
@ -0,0 +1,103 @@
|
|||
{
|
||||
"name": "composer/composer",
|
||||
"type": "library",
|
||||
"description": "Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.",
|
||||
"keywords": [
|
||||
"package",
|
||||
"dependency",
|
||||
"autoload"
|
||||
],
|
||||
"homepage": "https://getcomposer.org/",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nils Adermann",
|
||||
"email": "naderman@naderman.de",
|
||||
"homepage": "https://www.naderman.de"
|
||||
},
|
||||
{
|
||||
"name": "Jordi Boggiano",
|
||||
"email": "j.boggiano@seld.be",
|
||||
"homepage": "https://seld.be"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2.5 || ^8.0",
|
||||
"composer/ca-bundle": "^1.0",
|
||||
"composer/class-map-generator": "^1.0",
|
||||
"composer/metadata-minifier": "^1.0",
|
||||
"composer/semver": "^3.0",
|
||||
"composer/spdx-licenses": "^1.5.7",
|
||||
"composer/xdebug-handler": "^2.0.2 || ^3.0.3",
|
||||
"justinrainbow/json-schema": "^5.2.11",
|
||||
"psr/log": "^1.0 || ^2.0 || ^3.0",
|
||||
"seld/jsonlint": "^1.4",
|
||||
"seld/phar-utils": "^1.2",
|
||||
"symfony/console": "^5.4.11 || ^6.0.11",
|
||||
"symfony/filesystem": "^5.4 || ^6.0",
|
||||
"symfony/finder": "^5.4 || ^6.0",
|
||||
"symfony/process": "^5.4 || ^6.0",
|
||||
"react/promise": "^2.8",
|
||||
"composer/pcre": "^2.1 || ^3.1",
|
||||
"symfony/polyfill-php73": "^1.24",
|
||||
"symfony/polyfill-php80": "^1.24",
|
||||
"symfony/polyfill-php81": "^1.24",
|
||||
"seld/signal-handler": "^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "^6.0",
|
||||
"phpstan/phpstan": "^1.4.1",
|
||||
"phpstan/phpstan-phpunit": "^1.0",
|
||||
"phpstan/phpstan-deprecation-rules": "^1",
|
||||
"phpstan/phpstan-strict-rules": "^1",
|
||||
"phpstan/phpstan-symfony": "^1.2.10"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-openssl": "Enabling the openssl extension allows you to access https URLs for repositories and packages",
|
||||
"ext-zip": "Enabling the zip extension allows you to unzip archives",
|
||||
"ext-zlib": "Allow gzip compression of HTTP requests"
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "7.2.5"
|
||||
},
|
||||
"platform-check": false
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "2.5-dev"
|
||||
},
|
||||
"phpstan": {
|
||||
"includes": [
|
||||
"phpstan/rules.neon"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Composer\\": "src/Composer"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Composer\\Test\\": "tests/Composer/Test"
|
||||
}
|
||||
},
|
||||
"bin": [
|
||||
"bin/composer"
|
||||
],
|
||||
"scripts": {
|
||||
"compile": "@php -dphar.readonly=0 bin/compile",
|
||||
"test": "@php simple-phpunit",
|
||||
"phpstan": "@php vendor/bin/phpstan analyse --configuration=phpstan/config.neon"
|
||||
},
|
||||
"scripts-descriptions": {
|
||||
"compile": "Compile composer.phar",
|
||||
"test": "Run all tests",
|
||||
"phpstan": "Runs PHPStan"
|
||||
},
|
||||
"support": {
|
||||
"issues": "https://github.com/composer/composer/issues",
|
||||
"irc": "ircs://irc.libera.chat:6697/composer"
|
||||
}
|
||||
}
|
2416
tests/old_tests/composer/lock_example.json
Normal file
2416
tests/old_tests/composer/lock_example.json
Normal file
File diff suppressed because it is too large
Load diff
39
tests/old_tests/example_project/README.md
Normal file
39
tests/old_tests/example_project/README.md
Normal file
|
@ -0,0 +1,39 @@
|
|||
# Example Project
|
||||
|
||||
This is a simple library that provides very basic functionality,
|
||||
this project is a means to test the compiler capabilities of NCC
|
||||
|
||||
|
||||
### Generating a project configuration file.
|
||||
|
||||
You can generate a project configuration file using the NCC
|
||||
command-line interface, you should run the command in the
|
||||
root directory of your project rather than the source directory.
|
||||
|
||||
The argument `src` allows you to specify the source directory
|
||||
which is required, otherwise NCC will assume the src directory is the current working directory.
|
||||
|
||||
```shell
|
||||
$ ls
|
||||
README.md src
|
||||
|
||||
$ ncc project create --src="src/ExampleLibrary" --package="com.example.library" --name="ExampleLibrary"
|
||||
Project successfully created
|
||||
|
||||
$ ls
|
||||
ncc project.json README.md src
|
||||
```
|
||||
|
||||
Upon creating the project, you will see a directory named `ncc`
|
||||
and a file named `project.json`, the `ncc` directory will simply
|
||||
contain extra information about the project, the file `project.json`
|
||||
contains information about the project itself, you can modify
|
||||
and change the contents of the project accordingly
|
||||
|
||||
This process only needs to be done once, any additional changes
|
||||
can be done manually by editing project.json
|
||||
|
||||
Once project.json is created, the project can be compiled using NCC
|
||||
|
||||
|
||||
### Compiling the project
|
3
tests/old_tests/example_project/scripts/unit.bash
Normal file
3
tests/old_tests/example_project/scripts/unit.bash
Normal file
|
@ -0,0 +1,3 @@
|
|||
echo "Hello World!"
|
||||
read -r -p "What is your name? " name
|
||||
echo "Hello $name"
|
4
tests/old_tests/example_project/scripts/unit.lua
Normal file
4
tests/old_tests/example_project/scripts/unit.lua
Normal file
|
@ -0,0 +1,4 @@
|
|||
print("Hello World!")
|
||||
print("What is your name?")
|
||||
name = io.read()
|
||||
print("Hello " .. name)
|
6
tests/old_tests/example_project/scripts/unit.pl
Normal file
6
tests/old_tests/example_project/scripts/unit.pl
Normal file
|
@ -0,0 +1,6 @@
|
|||
use warnings;
|
||||
print("Hello, World!\n");
|
||||
print("What is your name? ");
|
||||
my $name = <STDIN>;
|
||||
chomp($name);
|
||||
print("Hello, $name\n");
|
3
tests/old_tests/example_project/scripts/unit.py2
Normal file
3
tests/old_tests/example_project/scripts/unit.py2
Normal file
|
@ -0,0 +1,3 @@
|
|||
print('Hello World!')
|
||||
name = input('What is your name? ')
|
||||
print('Hello', name)
|
3
tests/old_tests/example_project/scripts/unit.py3
Normal file
3
tests/old_tests/example_project/scripts/unit.py3
Normal file
|
@ -0,0 +1,3 @@
|
|||
print('Hello World!')
|
||||
name = input('What is your name? ')
|
||||
print('Hello', name)
|
File diff suppressed because it is too large
Load diff
88799
tests/old_tests/example_project/src/ExampleLibrary/Data/last_names.txt
Normal file
88799
tests/old_tests/example_project/src/ExampleLibrary/Data/last_names.txt
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace old_tests\example_project\src\ExampleLibrary;
|
||||
|
||||
use old_tests\example_project\src\ExampleLibrary\Exceptions\FileNotFoundException;
|
||||
use old_tests\example_project\src\ExampleLibrary\Objects\Person;
|
||||
|
||||
class ExampleLibrary
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $FirstNames;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $LastNames;
|
||||
|
||||
/**
|
||||
* Public Constructor
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if(!file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'Data' . DIRECTORY_SEPARATOR . 'first_names.txt'))
|
||||
throw new FileNotFoundException('The file first_names.txt does not exist in the data directory.');
|
||||
|
||||
if(!file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'Data' . DIRECTORY_SEPARATOR . 'last_names.txt'))
|
||||
throw new FileNotFoundException('The file last_names.txt does not exist in the data directory.');
|
||||
|
||||
$first_names = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'Data' . DIRECTORY_SEPARATOR . 'first_names.txt');
|
||||
$this->FirstNames = explode("\n", $first_names);
|
||||
|
||||
$last_names = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'Data' . DIRECTORY_SEPARATOR . 'last_names.txt');
|
||||
$this->LastNames = explode("\n", $last_names);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of randomly generated
|
||||
*
|
||||
* @param int $amount
|
||||
* @return array
|
||||
* @throws \old_tests\example_project\src\ExampleLibrary\Exceptions\InvalidNameException
|
||||
*/
|
||||
public function generatePeople(int $amount=10): array
|
||||
{
|
||||
$results = [];
|
||||
|
||||
for ($k = 0 ; $k < $amount; $k++)
|
||||
{
|
||||
$FullName = implode(' ', [
|
||||
$this->FirstNames[array_rand($this->FirstNames)],
|
||||
$this->LastNames[array_rand($this->LastNames)]
|
||||
]);
|
||||
|
||||
$results[] = new Person($FullName);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/** @noinspection PhpPropertyOnlyWrittenInspection */
|
||||
|
||||
namespace old_tests\example_project\src\ExampleLibrary\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
class FileNotFoundException extends Exception
|
||||
{
|
||||
/**
|
||||
* @var Throwable|null
|
||||
*/
|
||||
private ?Throwable $previous;
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
*/
|
||||
public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
$this->message = $message;
|
||||
$this->code = $code;
|
||||
$this->previous = $previous;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
/** @noinspection PhpPropertyOnlyWrittenInspection */
|
||||
|
||||
namespace old_tests\example_project\src\ExampleLibrary\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
class InvalidNameException extends Exception
|
||||
{
|
||||
private ?Throwable $previous;
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
*/
|
||||
public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
$this->message = $message;
|
||||
$this->code = $code;
|
||||
$this->previous = $previous;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
<?php
|
||||
|
||||
namespace old_tests\example_project\src\ExampleLibrary\Objects;
|
||||
|
||||
use old_tests\example_project\src\ExampleLibrary\Exceptions\InvalidNameException;
|
||||
|
||||
class Person
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private string $FirstName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private string $LastName;
|
||||
|
||||
/**
|
||||
* Public Constructor
|
||||
*
|
||||
* @param string|null $name
|
||||
* @throws InvalidNameException
|
||||
*/
|
||||
public function __construct(?string $name=null)
|
||||
{
|
||||
if($name !== null)
|
||||
{
|
||||
$exploded_name = explode(' ', $name);
|
||||
|
||||
if(count($exploded_name) < 2)
|
||||
{
|
||||
throw new InvalidNameException('The given name must contain a first and last name.');
|
||||
}
|
||||
|
||||
$this->FirstName = $exploded_name[0];
|
||||
$this->LastName = $exploded_name[1];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the first name of the person.
|
||||
*
|
||||
* @param string $FirstName
|
||||
*/
|
||||
public function setFirstName(string $FirstName): void
|
||||
{
|
||||
$this->FirstName = $FirstName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last name of the person.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLastName(): string
|
||||
{
|
||||
return $this->LastName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the last name of the person.
|
||||
*
|
||||
* @param string $LastName
|
||||
*/
|
||||
public function setLastName(string $LastName): void
|
||||
{
|
||||
$this->LastName = $LastName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first name of the person.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFirstName(): string
|
||||
{
|
||||
return $this->FirstName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the person.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return implode(' ', [$this->FirstName, $this->LastName]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the person
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'first_name' => $this->FirstName,
|
||||
'last_name' => $this->LastName
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return Person
|
||||
*/
|
||||
public static function fromArray(array $data): Person
|
||||
{
|
||||
$person = new Person();
|
||||
|
||||
if(isset($data['first_name']))
|
||||
$person->FirstName = $data['first_name'];
|
||||
|
||||
if(isset($data['last_name']))
|
||||
$person->LastName = $data['last_name'];
|
||||
|
||||
return $person;
|
||||
}
|
||||
}
|
65
tests/old_tests/project_configuration/project.json
Normal file
65
tests/old_tests/project_configuration/project.json
Normal file
|
@ -0,0 +1,65 @@
|
|||
{
|
||||
"project": {
|
||||
"compiler": {
|
||||
"extension": "php",
|
||||
"minimum_version": "7.4",
|
||||
"maximum_version": "8.1"
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"assembly":{
|
||||
"name": "Example",
|
||||
"package": "com.example.library",
|
||||
"description": "An example project for NCC to build",
|
||||
"company": null,
|
||||
"product": null,
|
||||
"copyright": "Copyright (c) Test 2022",
|
||||
"trademark": null,
|
||||
"version": "1.0.0.0",
|
||||
"uid": "4aaa878e-b600-11ec-b909-0242ac120002"
|
||||
},
|
||||
"build": {
|
||||
"source_path": "src/ExampleLibrary",
|
||||
"default_configuration": "debug",
|
||||
"exclude_files": [
|
||||
"README.md"
|
||||
],
|
||||
"options": {},
|
||||
"scope": "user",
|
||||
"define_constants": {
|
||||
"ASSEMBLY_NAME": "%ASSEMBLY.NAME%",
|
||||
"ASSEMBLY_PACKAGE": "%ASSEMBLY.PACKAGE%",
|
||||
"ASSEMBLY_VERSION": "%ASSEMBLY.VERSION%",
|
||||
"ASSEMBLY_UID": "%ASSEMBLY.UID%"
|
||||
},
|
||||
"dependencies": [
|
||||
{"name": "mbstring", "source": "extension", "version": "latest"},
|
||||
{"name": "com.example.dependency", "source": "default@github/example/ncc_dependency", "version": "latest"},
|
||||
{"name": "com.symfony.process", "source": "symfony@cmoposer/process", "version": "latest"}
|
||||
],
|
||||
"configurations": [
|
||||
{
|
||||
"name": "debug",
|
||||
"options": {},
|
||||
"output_path": "build/debug",
|
||||
"define_constants": {
|
||||
"DEBUG": "1"
|
||||
},
|
||||
"exclude_files": [],
|
||||
"dependencies": [
|
||||
{"name": "x-debug", "source": "extension", "version": "latest"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "release",
|
||||
"options": {},
|
||||
"output_path": "build/release",
|
||||
"define_constants": {
|
||||
"DEBUG": "0"
|
||||
},
|
||||
"exclude_files": [],
|
||||
"dependencies": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue