Start of HHI for DbUnit

Started with TestCase and slowly going through the Hack errors thrown
from that.
parents
Pipeline #100 failed with stage
.hhconfig
.project
vendor
.DS_Store
before_script:
- "echo 'assume_php=false' > .hhconfig"
- composer install
cache:
paths:
- vendor/
hack:
script:
- hh_server --check .
tags:
- hhvm
packagist:
type: deploy
only:
- tags
script:
- "curl -X POST \
-H 'content-type:application/json' \
\"https://packagist.org/api/update-package?username=simon_w&apiToken=$PACKAGIST_TOKEN\" \
-d '{\"repository\":{\"url\":\"https://git.simon.geek.nz/91-carriage/dbunit-hhi.git\"}}'"
Copyright (c) 2016 91 Carriage
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
* Except as contained in this notice, the name(s) of the above copyright holders
shall not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# HHI files for DbUnit
This package provides HHI files for the [DbUnit package][dbunit]. It does
not provide any runtime functionality.
HHI files are files which tell the Hack tools about non-Hack code, providing the
necessary names and types to allow Hack to make sure you're using the non-Hack
code correctly.
## Installation
The easiest way to install this package is with [Composer][composer].
To do so, add `"91carriage/dbunit-hhi": "~2.0.0"` to the `require-dev` section
of your `composer.json` or run
`composer require --dev '91carriage/dbunit-hhi:~2.0.0'`.
It is not recommended to install this as part of your `requires` section as it
should only be used during development.
Manual installation simply involves downloading the provided source code and
copying it into your repository.
## Issues
Issues can be submitted to the [issue tacker][issues].
If you are unable to create an issue through this, or think that it should not
be publicly disclosed, they can also be emailed directly to
[issues@91carriage.com][issue-email] or brought to my attention on IRC, where I
go by the handles `simon_w` and `simon_w|air` in the offical [#hhvm][hhvm-irc]
channel on FreeNode.
## Contributing
Contributions are very welcome. Please make sure that you run `hh_client` in the
source directory with `assume_php=false` in your `.hhconfig` and no errors are
reported.
### Code style
For Hack files, the coding style is enforced by the `hh_format` command, which
is included with the Hack tools alongside `hh_client`. As the files are decl
files, you need to run `hh_format` with the `--yolo` option.
For other files, the basic requirements are:
* Lines are no more than 80 characters wherever possible.
* Indentation is 2 spaces.
* Unix-style (`\n`) line endings.
### File types
As these are HHI files, all files should be in [decl mode][decl-mode].
### Non-existent class types
If an object type is required and that object is in a different package or is
built into HHVM and doesn't yet have a HHI file, add the expected type as a
comment.
For example, if the function `foo` returns a `SplObject` and there's no inbuilt
HHI file for `SplObject`, the definition of `foo` would be:
```
function foo() /*: SplObject*/;
```
## License
This code is provided under the MIT (X11 variant) license. The full text of
which can be found in the [LICENSE.md](LICENSE.md) file.
<!-- Please keep these sorted alphabetically. -->
[composer]: https://getcomposer.org/
[dbunit]: https://phpunit.de/manual/current/en/database.html
[decl-mode]: http://docs.hhvm.com/hack/typechecker/modes#decl-mode
[hhvm-irc]: http://webchat.freenode.net/?channels=hhvm
[issue-email]: mailto:issues@91carriage.com
[issues]: https://git.simon.geek.nz/91-carriage/dbunit-hhi/issues
{
"name": "91carriage/dbunit-hhi",
"description": "HHI definitions for DbUnit",
"keywords": ["phpunit", "testing", "hhvm", "hack", "dbunit", "database", "xunit"],
"homepage": "https://git.simon.geek.nz/91-carriage/dbunit-hhi",
"license": ["MIT"],
"require": {
"hhvm": ">=3.9.0",
"91carriage/phpunit-hhi": "*"
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"conflict": {
"phpunit/dbunit": "<2.0.0"
},
"support": {
"issues": "https://git.simon.geek.nz/91-carriage/dbunit-hhi/issues",
"source": "https://git.simon.geek.nz/91-carriage/dbunit-hhi/tree/master"
},
"require-dev": {
"phpunit/dbunit": "2.0.x-dev"
}
}
This diff is collapsed.
<?hh // decl
abstract class PHPUnit_Extensions_Database_AbstractTester
implements PHPUnit_Extensions_Database_ITester {
protected PHPUnit_Extensions_Database_Operation_IDatabaseOperation
$setUpOperation;
protected PHPUnit_Extensions_Database_Operation_IDatabaseOperation
$tearDownOperation;
protected ?PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet;
protected ?string $schema;
public function __construct();
public function closeConnection(
PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection,
): void;
public function getDataSet(): ?PHPUnit_Extensions_Database_DataSet_IDataSet;
public function onSetUp(): void;
public function onTearDown(): void;
public function setDataSet(
PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet,
): void;
public function setSchema(string $schema): void;
public function setSetUpOperation(
PHPUnit_Extensions_Database_Operation_IDatabaseOperation $setUpOperation,
): void;
public function setTearDownOperation(
PHPUnit_Extensions_Database_Operation_IDatabaseOperation $tearDownOperation,
): void;
protected function getSchema(): ?string;
protected function getSetUpOperation(
): PHPUnit_Extensions_Database_Operation_IDatabaseOperation;
protected function getTearDownOperation(
): PHPUnit_Extensions_Database_Operation_IDatabaseOperation;
}
<?hh // decl
abstract class PHPUnit_Extensions_Database_DataSet_AbstractDataSet
implements PHPUnit_Extensions_Database_DataSet_IDataSet {
protected abstract function createIterator(
bool $reverse = false,
): PHPUnit_Extensions_Database_DataSet_ITableIterator;
public function getTableNames(): array<string>;
public function getTableMetaData(
string $tableName,
): PHPUnit_Extensions_Database_DataSet_ITableMetaData;
public function getTable(
string $tableName,
): ?PHPUnit_Extensions_Database_DataSet_ITable;
public function getIterator(
): PHPUnit_Extensions_Database_DataSet_ITableIterator;
public function getReverseIterator(
): PHPUnit_Extensions_Database_DataSet_ITableIterator;
public function matches(
PHPUnit_Extensions_Database_DataSet_IDataSet $other,
): bool;
public function __toString(): string;
}
<?hh // decl
abstract class PHPUnit_Extensions_Database_DataSet_AbstractXmlDataSet
extends PHPUnit_Extensions_Database_DataSet_AbstractDataSet {
protected array<string, PHPUnit_Extensions_Database_DataSet_ITable>
$tables = [];
protected SimpleXMLElement $xmlFileContents;
public function __construct(string $xmlFile);
protected abstract function getTableInfo(
array &$tableColumns,
array &$tableValues,
): void;
protected function createTables(
array &$tableColumns,
array &$tableValues,
): void;
protected function getOrCreateTable(
string $tableName,
array $tableColumns,
): PHPUnit_Extensions_Database_DataSet_ITable;
protected function createIterator(
bool $reverse = FALSE,
): PHPUnit_Extensions_Database_DataSet_ITableIterator;
}
<?hh // decl
class PHPUnit_Extensions_Database_DataSet_ArrayDataSet
extends PHPUnit_Extensions_Database_DataSet_AbstractDataSet {
protected array<string, PHPUnit_Extensions_Database_DataSet_ITable>
$tables = [];
public function __construct(array $data);
protected function createIterator(
bool $reverse = false,
): PHPUnit_Extensions_Database_DataSet_DefaultTableIterator;
public function getTable(
string $tableName,
): PHPUnit_Extensions_Database_DataSet_ITable;
}
<?hh // decl
class PHPUnit_Extensions_Database_DataSet_DefaultTableIterator
implements PHPUnit_Extensions_Database_DataSet_ITableIterator {
public function __construct(
protected array<PHPUnit_Extensions_Database_DataSet_ITable> $tables,
protected bool $reverse = FALSE,
);
public function getTable(): PHPUnit_Extensions_Database_DataSet_ITable;
public function getTableMetaData(
): PHPUnit_Extensions_Database_ITableMetaData;
public function current(): PHPUnit_Extensions_Database_DataSet_ITable;
public function key(): string;
public function next(): void;
public function rewind(): void;
public function valid(): bool;
}
<?hh // decl
class PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet
extends PHPUnit_Extensions_Database_DataSet_AbstractXmlDataSet {
protected function getTableInfo(
array &$tableColumns,
array &$tableValues,
): void;
public static function write(
PHPUnit_Extensions_Database_DataSet_IDataSet $dataset,
string $filename,
): void;
}
<?hh // decl
interface PHPUnit_Extensions_Database_DataSet_IDataSet
extends IteratorAggregate<PHPUnit_Extensions_Database_DataSet_ITable> {
public function getTableNames(): array<string>;
public function getTableMetaData(
$tableName,
): PHPUnit_Extensions_Database_DataSet_ITableMetaData;
public function getTable(
$tableName,
): ?PHPUnit_Extensions_Database_DataSet_ITable;
public function getReverseIterator(
): PHPUnit_Extensions_Database_DataSet_ITableIterator;
public function matches(
PHPUnit_Extensions_Database_DataSet_IDataSet $other,
): bool;
}
<?hh // decl
interface PHPUnit_Extensions_Database_DataSet_ITable {
public function getTableMetaData(
): PHPUnit_Extensions_Database_DataSet_ITableMetaData;
public function getRowCount(): int;
public function getValue(int $row, int $column);
public function getRow(int $row): array;
public function matches(
PHPUnit_Extensions_Database_DataSet_ITable $other,
): bool;
}
<?hh // decl
interface PHPUnit_Extensions_Database_DataSet_ITableIterator
extends Iterator<PHPUnit_Extensions_Database_DataSet_ITable> {
public function getTable(): PHPUnit_Extensions_Database_DataSet_ITable;
public function getTableMetaData(
): PHPUnit_Extensions_Database_ITableMetaData;
}
<?hh // decl
interface PHPUnit_Extensions_Database_DataSet_ITableMetaData {
public function getColumns(): array<string>;
public function getPrimaryKeys(): array<string>;
public function getTableName(): string;
public function matches(
PHPUnit_Extensions_Database_DataSet_ITableMetaData $other,
): bool;
}
<?hh // decl
class PHPUnit_Extensions_Database_DefaultTester
extends PHPUnit_Extensions_Database_AbstractTester {
public function __construct(
protected PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection,
);
public function getConnection(
): PHPUnit_Extensions_Database_DB_IDatabaseConection;
}
<?hh // decl
class PHPUnit_Extensions_Database_Exception extends Exception {}
<?hh // decl
interface PHPUnit_Extensions_Database_IDatabaseListConsumer {
public function setDatabases(array $databases): void;
}
<?hh // decl
interface PHPUnit_Extensions_Database_ITester {
public function closeConnection(
PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection,
);
public function getConnection(
): PHPUnit_Extensions_Database_DB_IDatabaseConnection;
public function getDataSet(): ?PHPUnit_Extensions_Database_DataSet_IDataSet;
public function onSetUp(): void;
public function onTearDown(): void;
public function setDataSet(
PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet,
): void;
public function setSchema(string $schema): void;
public function setSetUpOperation(
PHPUnit_Extensions_Database_Operation_IDatabaseOperation $setUpOperation,
): void;
public function setTearDownOperation(
PHPUnit_Extensions_Database_Operation_IDatabaseOperation $tearDownOperation,
): void;
}
<?hh // decl
abstract class PHPUnit_Extensions_Database_TestCase
extends PHPUnit_Framework_TestCase {
use PHPUnit_Extensions_Database_TestCase_Trait;
}
<?hh // decl
trait PHPUnit_Extensions_Database_TestCase_Trait {
protected PHPUnit_Extensions_Database_ITester $databaseTester;
protected function closeConnection(
PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection,
): void;
protected abstract function getConnection(
): PHPUnit_Extensions_Database_DB_IDatabaseConnection;
protected function getDatabaseTester(): PHPUnit_Extensions_Database_ITester;
protected abstract function getDataSet(
): PHPUnit_Extensions_Database_DataSet_IDataSet;
protected function getSetUpOperation(
): PHPUnit_Extensions_Database_Operation_DatabaseOperation;
protected function getTearDownOperation(
): PHPUnit_Extensions_Database_Operation_DatabaseOperation;
protected function newDatabaseTester(): PHPUnit_Extensions_Database_ITester;
protected function createDefaultDBConnection(
PDO $connection,
string $schema = '',
): PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection;
protected function createArrayDataSet(
array $data,
): PHPUnit_Extensions_Database_DataSet_ArrayDataSet;
protected function createFlatXMLDataSet(
$xmlFile,
): PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet;
protected function createXMLDataSet(
$xmlFile,
): PHPUnit_Extensions_Database_DataSet_XmlDataSet;
protected function createMySQLXMLDataSet(
$xmlFile,
): PHPUnit_Extensions_Database_DataSet_MysqlXmlDataSet;
protected function getOperations(
): PHPUnit_Extensions_Database_Operation_Factory;
<<__Override>>
protected function setUp(): void;
protected function tearDown(): void;
public static function assertTablesEqual(
PHPUnit_Extensions_Database_DataSet_ITable $expected,
PHPUnit_Extensions_Database_DataSet_ITable $actual,
string $message = '',
): void;
public static function assertDataSetsEqual(
PHPUnit_Extensions_Database_DataSet_IDataSet $expected,
PHPUnit_Extensions_Database_DataSet_IDataSet $actual,
string $message = '',
): void;
public function assertTableRowCount(
string $tableName,
int $expected,
string $message = '',
): void;
public function assertTableContains(
array $expectedRow,
PHPUnit_Extensions_Database_DataSet_ITable $table,
string $message = '',
): void;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment