Fix the failing unit tests

refactor the codestyle for the tests we wanted to keep
This commit is contained in:
2017-10-17 06:41:19 -04:00
parent 8ae78ef047
commit 0cc8361929
40 changed files with 1395 additions and 5439 deletions

View File

@@ -11,8 +11,6 @@
], ],
"require": { "require": {
"codeception/codeception": "^2.2", "codeception/codeception": "^2.2",
"laravel/laravel": "^5.2",
"aedart/testing-laravel": "1.6.*",
"zackkitzmiller/tiny": "^1.2", "zackkitzmiller/tiny": "^1.2",
"webpatser/laravel-uuid": "^2.0" "webpatser/laravel-uuid": "^2.0"
}, },
@@ -20,6 +18,8 @@
"psr-4": { "psr-4": {
"XaiCorp\\AbcParser\\": "src/" "XaiCorp\\AbcParser\\": "src/"
} }
},
"require-dev": {
"mockery/mockery": "^1.0"
} }
} }

2216
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,7 @@ services:
image: abc-api/api:latest image: abc-api/api:latest
volumes: volumes:
- .:/var/www - .:/var/www
- ./:/opt/project - .:/opt/project
parser-composer: parser-composer:
image: composer/composer:alpine image: composer/composer:alpine

View File

@@ -1,23 +0,0 @@
<?php
namespace XaiCorp\AbcParser;
class Factory
{
protected $classMap = [
'TuneCollection' => null,
];
public function __construct(array $config = [])
{
}
public static function create($type)
{
return call_user_func([self, 'createInstance']);
}
public function createInstance($type)
{
return isset($this->classMap[$type])? new $this->classMap[$type]() : null;
}
}

View File

@@ -0,0 +1,17 @@
<?php
/**
* Created by PhpStorm.
* User: richard
* Date: 10/16/17
* Time: 6:14 AM
*/
namespace XaiCorp\AbcParser\Interfaces;
interface Repository
{
public function store($entity);
public function get($id);
}

View File

@@ -23,9 +23,14 @@ class Abc implements Builder
$this->collection->append($key, $data); $this->collection->append($key, $data);
} }
public function setOnCollection($key, $data)
{
$this->collection->set($key, $data);
}
public function getCollection() public function getCollection()
{ {
return count($this->collection) ? $this->collection : FALSE; return count($this->collection) ? $this->collection : false;
} }
public function newTune() public function newTune()
@@ -53,6 +58,11 @@ class Abc implements Builder
$this->currentSetting->append($key, $data); $this->currentSetting->append($key, $data);
} }
public function setOnSetting($key, $data)
{
$this->currentSetting->set($key, $data);
}
public function newPerson(array $data) public function newPerson(array $data)
{ {
return new Person($data); return new Person($data);
@@ -63,5 +73,6 @@ class Abc implements Builder
$this->currentSetting->set('music', trim($music)); $this->currentSetting->set('music', trim($music));
$this->currentTune->append('collection', $this->currentSetting); $this->currentTune->append('collection', $this->currentSetting);
$this->collection->append('collection', $this->currentTune); $this->collection->append('collection', $this->currentTune);
//TODO: save to repositories
} }
} }

View File

@@ -1,26 +0,0 @@
<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;
/**
* Define custom actions here
*/
}

View File

@@ -1,26 +0,0 @@
<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class FunctionalTester extends \Codeception\Actor
{
use _generated\FunctionalTesterActions;
/**
* Define custom actions here
*/
}

View File

@@ -1,10 +0,0 @@
<?php
namespace Helper;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class Acceptance extends \Codeception\Module
{
}

View File

@@ -1,10 +0,0 @@
<?php
namespace Helper;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class Functional extends \Codeception\Module
{
}

View File

@@ -1,4 +1,4 @@
<?php //[STAMP] 0313d1b3990d7fd01d357b6dec376b7f <?php //[STAMP] 1f8497625552088e64c5a9f542e900d2
namespace _generated; namespace _generated;
// This class was automatically generated by build task // This class was automatically generated by build task
@@ -19,20 +19,10 @@ trait AcceptanceTesterActions
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
* Sets the HTTP header to the passed value - which is used on * Alias to `haveHttpHeader`
* subsequent HTTP requests through PhpBrowser.
* *
* Example: * @param $name
* ```php * @param $value
* <?php
* $I->setHeader('X-Requested-With', 'Codeception');
* $I->amOnPage('test-headers.php');
* ?>
* ```
*
* @param string $name the name of the request header
* @param string $value the value to set it to for subsequent
* requests
* @see \Codeception\Module\PhpBrowser::setHeader() * @see \Codeception\Module\PhpBrowser::setHeader()
*/ */
public function setHeader($name, $value) { public function setHeader($name, $value) {
@@ -40,31 +30,6 @@ trait AcceptanceTesterActions
} }
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Deletes the header with the passed name. Subsequent requests
* will not have the deleted header in its request.
*
* Example:
* ```php
* <?php
* $I->setHeader('X-Requested-With', 'Codeception');
* $I->amOnPage('test-headers.php');
* // ...
* $I->deleteHeader('X-Requested-With');
* $I->amOnPage('some-other-page.php');
* ?>
* ```
*
* @param string $name the name of the header to delete.
* @see \Codeception\Module\PhpBrowser::deleteHeader()
*/
public function deleteHeader($name) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('deleteHeader', func_get_args()));
}
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
@@ -152,6 +117,66 @@ trait AcceptanceTesterActions
} }
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Sets the HTTP header to the passed value - which is used on
* subsequent HTTP requests through PhpBrowser.
*
* Example:
* ```php
* <?php
* $I->haveHttpHeader('X-Requested-With', 'Codeception');
* $I->amOnPage('test-headers.php');
* ?>
* ```
*
* To use special chars in Header Key use HTML Character Entities:
* Example:
* Header with underscore - 'Client_Id'
* should be represented as - 'Client&#x0005F;Id' or 'Client&#95;Id'
*
* ```php
* <?php
* $I->haveHttpHeader('Client&#95;Id', 'Codeception');
* ?>
* ```
*
* @param string $name the name of the request header
* @param string $value the value to set it to for subsequent
* requests
* @see \Codeception\Lib\InnerBrowser::haveHttpHeader()
*/
public function haveHttpHeader($name, $value) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('haveHttpHeader', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Deletes the header with the passed name. Subsequent requests
* will not have the deleted header in its request.
*
* Example:
* ```php
* <?php
* $I->haveHttpHeader('X-Requested-With', 'Codeception');
* $I->amOnPage('test-headers.php');
* // ...
* $I->deleteHeader('X-Requested-With');
* $I->amOnPage('some-other-page.php');
* ?>
* ```
*
* @param string $name the name of the header to delete.
* @see \Codeception\Lib\InnerBrowser::deleteHeader()
*/
public function deleteHeader($name) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('deleteHeader', func_get_args()));
}
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
@@ -165,7 +190,7 @@ trait AcceptanceTesterActions
* $I->amOnPage('/register'); * $I->amOnPage('/register');
* ``` * ```
* *
* @param $page * @param string $page
* @see \Codeception\Lib\InnerBrowser::amOnPage() * @see \Codeception\Lib\InnerBrowser::amOnPage()
*/ */
public function amOnPage($page) { public function amOnPage($page) {
@@ -225,6 +250,7 @@ trait AcceptanceTesterActions
* $I->see('Logout'); // I can suppose user is logged in * $I->see('Logout'); // I can suppose user is logged in
* $I->see('Sign Up', 'h1'); // I can suppose it's a signup page * $I->see('Sign Up', 'h1'); // I can suppose it's a signup page
* $I->see('Sign Up', '//body/h1'); // with XPath * $I->see('Sign Up', '//body/h1'); // with XPath
* $I->see('Sign Up', ['css' => 'body h1']); // with strict CSS locator
* ``` * ```
* *
* Note that the search is done after stripping all HTML tags from the body, * Note that the search is done after stripping all HTML tags from the body,
@@ -241,8 +267,8 @@ trait AcceptanceTesterActions
* *
* For checking the raw source code, use `seeInSource()`. * For checking the raw source code, use `seeInSource()`.
* *
* @param $text * @param string $text
* @param null $selector * @param string $selector optional
* Conditional Assertion: Test won't be stopped on fail * Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::see() * @see \Codeception\Lib\InnerBrowser::see()
*/ */
@@ -262,6 +288,7 @@ trait AcceptanceTesterActions
* $I->see('Logout'); // I can suppose user is logged in * $I->see('Logout'); // I can suppose user is logged in
* $I->see('Sign Up', 'h1'); // I can suppose it's a signup page * $I->see('Sign Up', 'h1'); // I can suppose it's a signup page
* $I->see('Sign Up', '//body/h1'); // with XPath * $I->see('Sign Up', '//body/h1'); // with XPath
* $I->see('Sign Up', ['css' => 'body h1']); // with strict CSS locator
* ``` * ```
* *
* Note that the search is done after stripping all HTML tags from the body, * Note that the search is done after stripping all HTML tags from the body,
@@ -278,8 +305,8 @@ trait AcceptanceTesterActions
* *
* For checking the raw source code, use `seeInSource()`. * For checking the raw source code, use `seeInSource()`.
* *
* @param $text * @param string $text
* @param null $selector * @param string $selector optional
* @see \Codeception\Lib\InnerBrowser::see() * @see \Codeception\Lib\InnerBrowser::see()
*/ */
public function see($text, $selector = null) { public function see($text, $selector = null) {
@@ -298,6 +325,7 @@ trait AcceptanceTesterActions
* $I->dontSee('Login'); // I can suppose user is already logged in * $I->dontSee('Login'); // I can suppose user is already logged in
* $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page
* $I->dontSee('Sign Up','//body/h1'); // with XPath * $I->dontSee('Sign Up','//body/h1'); // with XPath
* $I->dontSee('Sign Up', ['css' => 'body h1']); // with strict CSS locator
* ``` * ```
* *
* Note that the search is done after stripping all HTML tags from the body, * Note that the search is done after stripping all HTML tags from the body,
@@ -314,8 +342,8 @@ trait AcceptanceTesterActions
* *
* For checking the raw source code, use `seeInSource()`. * For checking the raw source code, use `seeInSource()`.
* *
* @param $text * @param string $text
* @param null $selector * @param string $selector optional
* Conditional Assertion: Test won't be stopped on fail * Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::dontSee() * @see \Codeception\Lib\InnerBrowser::dontSee()
*/ */
@@ -333,6 +361,7 @@ trait AcceptanceTesterActions
* $I->dontSee('Login'); // I can suppose user is already logged in * $I->dontSee('Login'); // I can suppose user is already logged in
* $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page
* $I->dontSee('Sign Up','//body/h1'); // with XPath * $I->dontSee('Sign Up','//body/h1'); // with XPath
* $I->dontSee('Sign Up', ['css' => 'body h1']); // with strict CSS locator
* ``` * ```
* *
* Note that the search is done after stripping all HTML tags from the body, * Note that the search is done after stripping all HTML tags from the body,
@@ -349,8 +378,8 @@ trait AcceptanceTesterActions
* *
* For checking the raw source code, use `seeInSource()`. * For checking the raw source code, use `seeInSource()`.
* *
* @param $text * @param string $text
* @param null $selector * @param string $selector optional
* @see \Codeception\Lib\InnerBrowser::dontSee() * @see \Codeception\Lib\InnerBrowser::dontSee()
*/ */
public function dontSee($text, $selector = null) { public function dontSee($text, $selector = null) {
@@ -445,8 +474,8 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $text * @param string $text
* @param null $url * @param string $url optional
* Conditional Assertion: Test won't be stopped on fail * Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::seeLink() * @see \Codeception\Lib\InnerBrowser::seeLink()
*/ */
@@ -466,8 +495,8 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $text * @param string $text
* @param null $url * @param string $url optional
* @see \Codeception\Lib\InnerBrowser::seeLink() * @see \Codeception\Lib\InnerBrowser::seeLink()
*/ */
public function seeLink($text, $url = null) { public function seeLink($text, $url = null) {
@@ -488,8 +517,8 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $text * @param string $text
* @param null $url * @param string $url optional
* Conditional Assertion: Test won't be stopped on fail * Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::dontSeeLink() * @see \Codeception\Lib\InnerBrowser::dontSeeLink()
*/ */
@@ -509,8 +538,8 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $text * @param string $text
* @param null $url * @param string $url optional
* @see \Codeception\Lib\InnerBrowser::dontSeeLink() * @see \Codeception\Lib\InnerBrowser::dontSeeLink()
*/ */
public function dontSeeLink($text, $url = null) { public function dontSeeLink($text, $url = null) {
@@ -532,7 +561,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $uri * @param string $uri
* Conditional Assertion: Test won't be stopped on fail * Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl()
*/ */
@@ -553,7 +582,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $uri * @param string $uri
* @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl()
*/ */
public function seeInCurrentUrl($uri) { public function seeInCurrentUrl($uri) {
@@ -572,7 +601,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $uri * @param string $uri
* Conditional Assertion: Test won't be stopped on fail * Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl()
*/ */
@@ -590,7 +619,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $uri * @param string $uri
* @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl()
*/ */
public function dontSeeInCurrentUrl($uri) { public function dontSeeInCurrentUrl($uri) {
@@ -611,7 +640,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $uri * @param string $uri
* Conditional Assertion: Test won't be stopped on fail * Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals()
*/ */
@@ -631,7 +660,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $uri * @param string $uri
* @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals()
*/ */
public function seeCurrentUrlEquals($uri) { public function seeCurrentUrlEquals($uri) {
@@ -652,7 +681,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $uri * @param string $uri
* Conditional Assertion: Test won't be stopped on fail * Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals()
*/ */
@@ -672,7 +701,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $uri * @param string $uri
* @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals()
*/ */
public function dontSeeCurrentUrlEquals($uri) { public function dontSeeCurrentUrlEquals($uri) {
@@ -692,7 +721,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $uri * @param string $uri
* Conditional Assertion: Test won't be stopped on fail * Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches()
*/ */
@@ -711,7 +740,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $uri * @param string $uri
* @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches()
*/ */
public function seeCurrentUrlMatches($uri) { public function seeCurrentUrlMatches($uri) {
@@ -731,7 +760,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $uri * @param string $uri
* Conditional Assertion: Test won't be stopped on fail * Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches()
*/ */
@@ -750,7 +779,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $uri * @param string $uri
* @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches()
*/ */
public function dontSeeCurrentUrlMatches($uri) { public function dontSeeCurrentUrlMatches($uri) {
@@ -761,7 +790,7 @@ trait AcceptanceTesterActions
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
* Executes the given regular expression against the current URI and returns the first match. * Executes the given regular expression against the current URI and returns the first capturing group.
* If no parameters are provided, the full URI is returned. * If no parameters are provided, the full URI is returned.
* *
* ``` php * ``` php
@@ -771,7 +800,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param null $uri * @param string $uri optional
* *
* @return mixed * @return mixed
* @see \Codeception\Lib\InnerBrowser::grabFromCurrentUrl() * @see \Codeception\Lib\InnerBrowser::grabFromCurrentUrl()
@@ -864,8 +893,8 @@ trait AcceptanceTesterActions
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
* Checks that the given input field or textarea contains the given value. * Checks that the given input field or textarea *equals* (i.e. not just contains) the given value.
* For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath. * Fields are matched by label text, the "name" attribute, CSS, or XPath.
* *
* ``` php * ``` php
* <?php * <?php
@@ -889,8 +918,8 @@ trait AcceptanceTesterActions
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
* Checks that the given input field or textarea contains the given value. * Checks that the given input field or textarea *equals* (i.e. not just contains) the given value.
* For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath. * Fields are matched by label text, the "name" attribute, CSS, or XPath.
* *
* ``` php * ``` php
* <?php * <?php
@@ -1200,7 +1229,7 @@ trait AcceptanceTesterActions
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
* Submits the given form on the page, optionally with the given form * Submits the given form on the page, with the given form
* values. Pass the form field's values as an array in the second * values. Pass the form field's values as an array in the second
* parameter. * parameter.
* *
@@ -1418,6 +1447,15 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* Or provide an associative array for the second argument to specifically define which selection method should be used:
*
* ``` php
* <?php
* $I->selectOption('Which OS do you use?', array('text' => 'Windows')); // Only search by text 'Windows'
* $I->selectOption('Which OS do you use?', array('value' => 'windows')); // Only search by value 'windows'
* ?>
* ```
*
* @param $select * @param $select
* @param $option * @param $option
* @see \Codeception\Lib\InnerBrowser::selectOption() * @see \Codeception\Lib\InnerBrowser::selectOption()
@@ -1468,7 +1506,7 @@ trait AcceptanceTesterActions
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
* Attaches a file relative to the Codeception data directory to the given file upload field. * Attaches a file relative to the Codeception `_data` directory to the given file upload field.
* *
* ``` php * ``` php
* <?php * <?php
@@ -1561,7 +1599,8 @@ trait AcceptanceTesterActions
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
* Finds and returns the text contents of the given element. * Finds and returns the text contents of the given element.
* If a fuzzy locator is used, the element is found using CSS, XPath, and by matching the full page source by regular expression. * If a fuzzy locator is used, the element is found using CSS, XPath,
* and by matching the full page source by regular expression.
* *
* ``` php * ``` php
* <?php * <?php
@@ -1691,6 +1730,21 @@ trait AcceptanceTesterActions
} }
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Grabs current page source code.
*
* @throws ModuleException if no page was opened.
*
* @return string Current page source code.
* @see \Codeception\Lib\InnerBrowser::grabPageSource()
*/
public function grabPageSource() {
return $this->getScenario()->runStep(new \Codeception\Step\Action('grabPageSource', func_get_args()));
}
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
@@ -1898,9 +1952,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* @param $selector * @param $selector
* @param mixed $expected : * @param mixed $expected int or int[]
* - string: strict number
* - array: range of numbers [0,10]
* Conditional Assertion: Test won't be stopped on fail * Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::seeNumberOfElements() * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements()
*/ */
@@ -1919,9 +1971,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* @param $selector * @param $selector
* @param mixed $expected : * @param mixed $expected int or int[]
* - string: strict number
* - array: range of numbers [0,10]
* @see \Codeception\Lib\InnerBrowser::seeNumberOfElements() * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements()
*/ */
public function seeNumberOfElements($selector, $expected) { public function seeNumberOfElements($selector, $expected) {
@@ -2041,9 +2091,15 @@ trait AcceptanceTesterActions
* *
* Checks that response code is equal to value provided. * Checks that response code is equal to value provided.
* *
* @param $code * ```php
* <?php
* $I->seeResponseCodeIs(200);
* *
* @return mixed * // recommended \Codeception\Util\HttpCode
* $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK);
* ```
*
* @param $code
* Conditional Assertion: Test won't be stopped on fail * Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs()
*/ */
@@ -2055,9 +2111,15 @@ trait AcceptanceTesterActions
* *
* Checks that response code is equal to value provided. * Checks that response code is equal to value provided.
* *
* @param $code * ```php
* <?php
* $I->seeResponseCodeIs(200);
* *
* @return mixed * // recommended \Codeception\Util\HttpCode
* $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK);
* ```
*
* @param $code
* @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs()
*/ */
public function seeResponseCodeIs($code) { public function seeResponseCodeIs($code) {
@@ -2065,6 +2127,45 @@ trait AcceptanceTesterActions
} }
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that response code is equal to value provided.
*
* ```php
* <?php
* $I->dontSeeResponseCodeIs(200);
*
* // recommended \Codeception\Util\HttpCode
* $I->dontSeeResponseCodeIs(\Codeception\Util\HttpCode::OK);
* ```
* @param $code
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::dontSeeResponseCodeIs()
*/
public function cantSeeResponseCodeIs($code) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeResponseCodeIs', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that response code is equal to value provided.
*
* ```php
* <?php
* $I->dontSeeResponseCodeIs(200);
*
* // recommended \Codeception\Util\HttpCode
* $I->dontSeeResponseCodeIs(\Codeception\Util\HttpCode::OK);
* ```
* @param $code
* @see \Codeception\Lib\InnerBrowser::dontSeeResponseCodeIs()
*/
public function dontSeeResponseCodeIs($code) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeResponseCodeIs', func_get_args()));
}
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *

View File

@@ -1,4 +1,4 @@
<?php //[STAMP] e5fb1777708efe70c0e9573bd3d7b4f7 <?php //[STAMP] e5c8b753550e51a399c3237c77520b8f
namespace _generated; namespace _generated;
// This class was automatically generated by build task // This class was automatically generated by build task
@@ -20,14 +20,29 @@ trait UnitTesterActions
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
* Checks that two variables are equal. * Checks that two variables are equal. If you're comparing floating-point values,
* you can specify the optional "delta" parameter which dictates how great of a precision
* error are you willing to tolerate in order to consider the two values equal.
*
* Regular example:
* ```php
* <?php
* $I->assertEquals($element->getChildrenCount(), 5);
* ```
*
* Floating-point example:
* ```php
* <?php
* $I->assertEquals($calculator->add(0.1, 0.2), 0.3, 'Calculator should add the two numbers correctly.', 0.01);
* ```
* *
* @param $expected * @param $expected
* @param $actual * @param $actual
* @param string $message * @param string $message
* @param float $delta
* @see \Codeception\Module\Asserts::assertEquals() * @see \Codeception\Module\Asserts::assertEquals()
*/ */
public function assertEquals($expected, $actual, $message = null) { public function assertEquals($expected, $actual, $message = null, $delta = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEquals', func_get_args())); return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEquals', func_get_args()));
} }
@@ -35,14 +50,29 @@ trait UnitTesterActions
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
* Checks that two variables are not equal * Checks that two variables are not equal. If you're comparing floating-point values,
* you can specify the optional "delta" parameter which dictates how great of a precision
* error are you willing to tolerate in order to consider the two values not equal.
*
* Regular example:
* ```php
* <?php
* $I->assertNotEquals($element->getChildrenCount(), 0);
* ```
*
* Floating-point example:
* ```php
* <?php
* $I->assertNotEquals($calculator->add(0.1, 0.2), 0.4, 'Calculator should add the two numbers correctly.', 0.01);
* ```
* *
* @param $expected * @param $expected
* @param $actual * @param $actual
* @param string $message * @param string $message
* @param float $delta
* @see \Codeception\Module\Asserts::assertNotEquals() * @see \Codeception\Module\Asserts::assertNotEquals()
*/ */
public function assertNotEquals($expected, $actual, $message = null) { public function assertNotEquals($expected, $actual, $message = null, $delta = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEquals', func_get_args())); return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEquals', func_get_args()));
} }
@@ -92,17 +122,6 @@ trait UnitTesterActions
} }
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @deprecated
* @see \Codeception\Module\Asserts::assertGreaterThen()
*/
public function assertGreaterThen($expected, $actual, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThen', func_get_args()));
}
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
@@ -118,17 +137,6 @@ trait UnitTesterActions
} }
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @deprecated
* @see \Codeception\Module\Asserts::assertGreaterThenOrEqual()
*/
public function assertGreaterThenOrEqual($expected, $actual, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThenOrEqual', func_get_args()));
}
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
@@ -219,6 +227,36 @@ trait UnitTesterActions
} }
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that a string starts with the given prefix.
*
* @param string $prefix
* @param string $string
* @param string $message
* @see \Codeception\Module\Asserts::assertStringStartsWith()
*/
public function assertStringStartsWith($prefix, $string, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringStartsWith', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that a string doesn't start with the given prefix.
*
* @param string $prefix
* @param string $string
* @param string $message
* @see \Codeception\Module\Asserts::assertStringStartsNotWith()
*/
public function assertStringStartsNotWith($prefix, $string, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringStartsNotWith', func_get_args()));
}
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
@@ -334,13 +372,93 @@ trait UnitTesterActions
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
* Fails the test with message. * @param $expected
* * @param $actual
* @param $message * @param $description
* @see \Codeception\Module\Asserts::fail() * @see \Codeception\Module\Asserts::assertGreaterOrEquals()
*/ */
public function fail($message) { public function assertGreaterOrEquals($expected, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('fail', func_get_args())); return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterOrEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $expected
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertLessOrEquals()
*/
public function assertLessOrEquals($expected, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessOrEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertIsEmpty()
*/
public function assertIsEmpty($actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsEmpty', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $key
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertArrayHasKey()
*/
public function assertArrayHasKey($key, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayHasKey', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $key
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertArrayNotHasKey()
*/
public function assertArrayNotHasKey($key, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayNotHasKey', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that array contains subset.
*
* @param array $subset
* @param array $array
* @param bool $strict
* @param string $message
* @see \Codeception\Module\Asserts::assertArraySubset()
*/
public function assertArraySubset($subset, $array, $strict = null, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArraySubset', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $expectedCount
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertCount()
*/
public function assertCount($expectedCount, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertCount', func_get_args()));
} }
@@ -357,6 +475,79 @@ trait UnitTesterActions
} }
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $class
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertNotInstanceOf()
*/
public function assertNotInstanceOf($class, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotInstanceOf', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $type
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertInternalType()
*/
public function assertInternalType($type, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInternalType', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Fails the test with message.
*
* @param $message
* @see \Codeception\Module\Asserts::fail()
*/
public function fail($message) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('fail', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Handles and checks exception called inside callback function.
* Either exception class name or exception instance should be provided.
*
* ```php
* <?php
* $I->expectException(MyException::class, function() {
* $this->doSomethingBad();
* });
*
* $I->expectException(new MyException(), function() {
* $this->doSomethingBad();
* });
* ```
* If you want to check message or exception code, you can pass them with exception instance:
* ```php
* <?php
* // will check that exception MyException is thrown with "Don't do bad things" message
* $I->expectException(new MyException("Don't do bad things"), function() {
* $this->doSomethingBad();
* });
* ```
*
* @param $exception string or \Exception
* @param $callback
* @see \Codeception\Module\Asserts::expectException()
*/
public function expectException($exception, $callback) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('expectException', func_get_args()));
}
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *

View File

@@ -1,12 +0,0 @@
# Codeception Test Suite Configuration
#
# Suite for acceptance tests.
# Perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate suite.
class_name: AcceptanceTester
modules:
enabled:
- PhpBrowser:
url: http://localhost/myapp
- \Helper\Acceptance

View File

@@ -1,2 +0,0 @@
<?php
// Here you can initialize variables that will be available to your tests

View File

@@ -1,13 +0,0 @@
# Codeception Test Suite Configuration
#
# Suite for functional (integration) tests
# Emulate web requests and make application process them
# Include one of framework modules (Symfony2, Yii2, Laravel5) to use it
class_name: FunctionalTester
modules:
enabled:
# add framework module here
- \Helper\Functional
- Laravel5:
environment_file: .env.testing

View File

@@ -1,2 +0,0 @@
<?php
// Here you can initialize variables that will be available to your tests

View File

@@ -1,160 +0,0 @@
<?php
namespace laravel5;
use \UnitTester;
use \Codeception\Util\Stub;
use XaiCorp\AbcParser\Models\Laravel5\Abc;
use XaiCorp\AbcParser\Parser;
use XaiCorp\AbcParser\Interfaces\Builder;
//use Aedart\Testing\Laravel\Traits\TestHelperTrait;
class AbcParserCest
{
// use TestHelperTrait;
/**
* @var string
*/
protected $dataDir;
/**
* @var \XaiCorp\AbcParser\Interfaces\Builder
*/
protected $builder;
/**
* @var Parser;
*/
protected $parser;
public function __construct()
{
$this->dataDir = codecept_data_dir();
}
public function _before(UnitTester $I)
{
$this->builder = new Abc();
}
public function _after(UnitTester $I)
{
unset($builder);
}
// tests: trying to...
public function createParser(UnitTester $I)
{
$parser = new Parser($this->builder);
$I->assertInstanceOf(Parser::class, $parser);
}
public function seeParseEmptyAbcWithoutErrors(UnitTester $I)
{
$abc = '';
$parser = new Parser($this->builder);
$result = $parser->parseABC($abc);
$I->assertEmpty($result);
}
public function seeParseABCExample1(UnitTester $I)
{
$abc = file_get_contents($this->dataDir.'/abc/valid_abc_1.abc');
$parser = new Parser($this->builder);
$expected = [
1 => [
'X' => '3',
'M' => '4/4',
'K' => 'C',
'music' => 'gaab babc :|'
],
];
$result = $parser->parseABC($abc);
$I->assertNotEmpty($result);
$I->assertEquals($expected, $result);
}
public function seeParseABCExample2(UnitTester $I)
{
$abc = file_get_contents($this->dataDir.'/abc/valid_abc_2.abc');
$parser = new Parser($this->builder);
$expected = [
1 => [
'X' => '40',
'T' => ['Abbotts Bromley Horn Dance'],
'A' => ['trad'],
'C' => ['trad.'],
'D' => ['None'],
'G' => ['lute'],
'H' => [
'Thousand year old tradition',
'The Horns live in the church and are removed for the dance once a year'
],
'R' => ['Jig'],
'F' => ['none.abc'],
'B' => ['Traditional English tunes'],
'W' => ['None'],
'Q' => '1/8=80',
'L' => '1/8',
'M' => '6/8',
'N' => ['Traditional English'],
'O' => ['England'],
'Z' => ['Andy Hornby'],
'S' => ['http://www.leeds.ac.uk/music/Info/RRTuneBk/gettune/00000dab.html'],
'P' => 'ABC',
'K' => 'G',
'music' => 'e|B2e G2e|B2e E2G|FGA GAB|1AGF G2:|2AGF E2|
|e|c2e cde|A2c ABc|FGA GFE|_E=EF B,2g|
e2g efg|c2e cde|dcB AGF|E3E2
|:A|BcB e3|BcB f3|BcB AGF|1G2F G2:|2E3-E2|]'
],
];
$result = $parser->parseABC($abc);
$I->assertNotEmpty($result);
$I->assertEquals($expected, $result);
}
public function seeParseABCExample3(UnitTester $I)
{
$abc = file_get_contents($this->dataDir.'/abc/valid_abc_3.abc');
$parser = new Parser($this->builder);
$expected = [
'A' => ['trad'],
'C' => ['trad.'],
'D' => ['None'],
'H' => [
'Thousand year old tradition',
'The Horns live in the church and are removed for the dance once a year'
],
'R' => ['Jig'],
'F' => ['none.abc'],
'B' => ['Traditional English tunes'],
'L' => '1/8',
'M' => '6/8',
'N' => ['Traditional English'],
'O' => ['England'],
'S' => ['http://www.leeds.ac.uk/music/Info/RRTuneBk/gettune/00000dab.html'],
'Z' => ['Andy Hornby'],
1 => [
'X' => '3',
'M' => '4/4',
'K' => 'C',
'music' => 'gaab babc :|'
]
];
$result = $parser->parseABC($abc);
$I->assertNotEmpty($result);
$I->assertEquals($expected, $result);
}
}

View File

@@ -1,20 +0,0 @@
<?php
namespace laravel5;
use \FunctionalTester;
class CollectionCest
{
public function _before(FunctionalTester $I)
{
}
public function _after(FunctionalTester $I)
{
}
// tests
public function tryToTest(FunctionalTester $I)
{
}
}

View File

@@ -1,28 +0,0 @@
<?php
namespace laravel5;
use \FunctionalTester;
use XaiCorp\AbcParser\Models\Laravel5\TuneAttribute;
class TuneAttributeCest
{
public function _before(FunctionalTester $I)
{
}
public function _after(FunctionalTester $I)
{
}
// tests: trying to...
public function saveModel(FunctionalTester $I)
{
$model = new TuneAttribute();
$model->tune_id = 1;
$model->type = 'Title';
$model->string = 'a title';
$model->ordering = 1;
$I->assertCanSave($model);
}
}

View File

@@ -1,63 +0,0 @@
<?php
namespace Tests\Laravel5;
use Codeception\TestCase\Test;
use Aedart\Testing\Laravel\Traits\TestHelperTrait;
use XaiCorp\AbcParser\Models\Laravel5\Abc;
use XaiCorp\AbcParser\Models\Laravel5\Collection;
use XaiCorp\AbcParser\Models\Laravel5\CollectionAttribute;
use XaiCorp\AbcParser\Parser;
class AbcParserDBTest extends BaseDbTest
{
/**
* @var string
*/
protected $dataDir;
/**
* @var \XaiCorp\AbcParser\Interfaces\Builder60
*/
protected $builder;
/**
* @var \UnitTester
*/
protected $tester;
public function __construct()
{
$this->dataDir = codecept_data_dir();
}
// tests: trying to...
public function testSaveAbcFromExample1()
{
$abc = file_get_contents($this->dataDir.'/abc/valid_abc_1.abc');
$parser = new Parser($this->builder);
$result = $parser->parseABC($abc);
$this->assertTrue($result->save());
}
public function testSaveAbcFromExample2()
{
$abc = file_get_contents($this->dataDir.'/abc/valid_abc_2.abc');
$parser = new Parser($this->builder);
$result = $parser->parseABC($abc);
$this->assertTrue($result->save());
}
public function testSaveAbcFromExample3()
{
$abc = file_get_contents($this->dataDir.'/abc/valid_abc_3.abc');
$parser = new Parser($this->builder);
$result = $parser->parseABC($abc);
$this->assertTrue($result->save());
$this->seeInDatabase('tune_settings', []);
$this->seeInDatabase('tunes', []);
}
}

View File

@@ -1,53 +0,0 @@
<?php
namespace Tests\Laravel5;
use Codeception\TestCase\Test;
use Aedart\Testing\Laravel\Traits\TestHelperTrait;
use XaiCorp\AbcParser\Models\Laravel5\Abc;
class BaseDbTest extends Test
{
use TestHelperTrait;
/**
* @var \UnitTester
*/
protected $tester;
/**
* Define environment setup.
*
* @param \Illuminate\Foundation\Application $app
* @return void
*/
protected function getEnvironmentSetUp($app)
{
// Setup default database to use sqlite :memory:
$app['config']->set('database.default', 'testbench');
$app['config']->set('database.connections.testbench', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
]);
$app->setBasePath(dirname(dirname(dirname(__DIR__))));
$Artisan = $app->make('Artisan');
$Artisan::call('migrate');
}
protected function _before()
{
$this->startApplication();
$db = app()->make('db');
$db->beginTransaction();
$this->withFactories(__DIR__ . '/factories');
$this->builder = new Abc();
}
protected function _after()
{
$db = app()->make('db');
$db->rollBack();
$this->stopApplication();
}
}

View File

@@ -1,116 +0,0 @@
<?php
namespace Tests\Laravel5;
use Codeception\TestCase\Test;
use Aedart\Testing\Laravel\Traits\TestHelperTrait;
use Webpatser\Uuid\Uuid;
use XaiCorp\AbcParser\Models\Laravel5\Collection;
use XaiCorp\AbcParser\Models\Laravel5\CollectionAttribute;
use XaiCorp\AbcParser\Models\Laravel5\Person;
use XaiCorp\AbcParser\Models\Laravel5\Tune;
use XaiCorp\AbcParser\Models\Laravel5\TuneAttribute;
class CollectionAttributeTest extends BaseDbTest
{
/**
* @var \UnitTester
*/
protected $tester;
// tests: trying to...
public function testMakeModel()
{
$collection = factory(Collection::class)->create();
$type = 'Note';
$value = 'a title';
$ordering = 1;
$model = new CollectionAttribute();
$model->collection_id = $collection->id;
$model->type = $type;
$model->string = $value;
$model->ordering = $ordering;
$this->assertInstanceOf(CollectionAttribute::class, $model);
$this->assertEquals($collection->id, $model->collection_id);
$this->assertEquals($type, $model->type);
$this->assertEquals($value, $model->string);
$this->assertEquals($ordering, $model->ordering);
}
public function testMassAssignable()
{
$collection = factory(Collection::class)->create();
$type = 'Note';
$value = 'a title';
$ordering = 1;
$model = CollectionAttribute::create([
'collection_id' => $collection->id,
'type' => $type,
'string' => $value,
'ordering' => $ordering
]);
$this->assertInstanceOf(CollectionAttribute::class, $model);
$this->assertEquals($collection->id, $model->collection_id);
$this->assertEquals($type, $model->type);
$this->assertEquals($value, $model->string);
$this->assertEquals($ordering, $model->ordering);
}
public function testFactory()
{
$model = factory(CollectionAttribute::class)->make([]);
$this->assertInstanceOf(CollectionAttribute::class, $model);
$this->assertNotNull($model->collection_id);
$this->assertNotNull($model->type);
$this->assertNotNull($model->string);
$this->assertNotNull($model->ordering);
$this->assertTrue($model->save(), json_encode($model->getMessages()));
}
public function testValidationAppliedOnSave()
{
$model = factory(CollectionAttribute::class)->make([]);
$model->type = 'NotType';
$this->assertFalse($model->save());
}
public function testTypeValidation()
{
$model = factory(CollectionAttribute::class)->make([]);
$model->type = 'NotType';
$this->assertFalse($model->validate());
}
public function testTuneIdValidation()
{
$model = factory(CollectionAttribute::class)->make([]);
$model->collection_id = Uuid::generate(4);
$this->assertFalse($model->validate());
}
public function testStringValidation()
{
$longString = '';
for ($i=0; $i < 300; $i++) {
$longString .= 's';
}
$model = factory(CollectionAttribute::class)->make([]);
$model->string = $longString;
$this->assertFalse($model->validate());
}
public function testOrderingValidation()
{
$model = factory(CollectionAttribute::class)->make([]);
$model->ordering = "fourth";
$this->assertFalse($model->validate());
}
}

View File

@@ -1,523 +0,0 @@
<?php
namespace Tests\Laravel5;
use Codeception\TestCase\Test;
use Aedart\Testing\Laravel\Traits\TestHelperTrait;
use Faker\Test\Provider\BaseTest;
use XaiCorp\AbcParser\Models\Laravel5\Collection;
use XaiCorp\AbcParser\Models\Laravel5\CollectionAttribute;
class CollectionTest extends BaseDbTest
{
// use TestHelperTrait;
// /**
// * @var \UnitTester
// */
// protected $tester;
/**
* Define environment setup.
*
* @param \Illuminate\Foundation\Application $app
* @return void
*/
// protected function getEnvironmentSetUp($app)
// {
// // Setup default database to use sqlite :memory:
// $app['config']->set('database.default', 'testbench');
// $app['config']->set('database.connections.testbench', [
// 'driver' => 'sqlite',
// 'database' => ':memory:',
// 'prefix' => '',
// ]);
// $app->setBasePath(dirname(dirname(dirname(__DIR__))));
// $Artisan = $app->make('Artisan');
// $Artisan::call('migrate');
// }
//
//
// protected function _before()
// {
// $this->startApplication();
// $db = app()->make('db');
// $db->beginTransaction();
//
// $this->withFactories(__DIR__.'/factories');
// }
//
// protected function _after()
// {
// $db = app()->make('db');
// $db->rollBack();
// $this->stopApplication();
// }
// tests: trying to...
public function testMakeModel()
{
$name = "test1";
$model = new Collection();
$model->name = $name;
$this->assertInstanceOf(Collection::class, $model);
$this->assertEquals($name, $model->name);
}
public function testNameIsMassAssignable()
{
$name = "test1";
$model = Collection::create(['name'=>$name]);
$this->assertInstanceOf(Collection::class, $model);
$this->assertEquals($name, $model->name);
}
public function testFactorySetsName()
{
$model = factory(Collection::class)->make([]);
$this->assertInstanceOf(Collection::class, $model);
$this->assertNotEmpty($model->name);
}
public function testAppendToCollection()
{
$setting = new \stdClass();
$model = factory(Collection::class)->make([]);
$result = $model->appendSetting($setting);
$this->assertInstanceOf(\Illuminate\Support\Collection::class, $result);
$this->assertContains($setting, $result);
}
public function testCanGetAuthorAttribute()
{
$string = 'Arthur';
$model = factory(Collection::class)->create([]);
$attr = factory(CollectionAttribute::class)->create([
'collection_id' => $model->id,
'type' => 'Author',
'string' => $string,
]);
$model = $model->fresh();
$this->assertInstanceOf(Collection::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($string, $model->A[0]);
}
public function testSetAuthorAttribute()
{
$values = ['England', 'Scotland'];
$model = factory(Collection::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->A = $values;
$this->assertEquals($values[0], $model->A[0]);
$this->assertEquals($values[1], $model->A[1]);
}
public function testAuthorAttributeSaves()
{
$values = ['England', 'Scotland'];
$model = factory(Collection::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->A = $values;
$model->save();
$model = $model->fresh();
$this->assertEquals($values[0], $model->A[0]);
$this->assertEquals($values[1], $model->A[1]);
}
public function testCanGetComposerAttribute()
{
$string = 'Arthur';
$model = factory(Collection::class)->create([]);
$attr = factory(CollectionAttribute::class)->create([
'collection_id' => $model->id,
'type' => 'Composer',
'string' => $string,
]);
$model = $model->fresh();
$this->assertInstanceOf(Collection::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($string, $model->C[0]);
}
public function testSetComposerAttribute()
{
$values = ['England', 'Scotland'];
$model = factory(Collection::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->C = $values;
$this->assertEquals($values[0], $model->C[0]);
$this->assertEquals($values[1], $model->C[1]);
}
public function testComposerAttributeSaves()
{
$values = ['England', 'Scotland'];
$model = factory(Collection::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->C = $values;
$model->save();
$model = $model->fresh();
$this->assertEquals($values[0], $model->C[0]);
$this->assertEquals($values[1], $model->C[1]);
}
public function testCanGetDiscographyAttribute()
{
$string = 'Arthur';
$model = factory(Collection::class)->create([]);
$attr = factory(CollectionAttribute::class)->create([
'collection_id' => $model->id,
'type' => 'Discography',
'string' => $string,
]);
$model = $model->fresh();
$this->assertInstanceOf(Collection::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($string, $model->D[0]);
}
public function testSetDiscographyAttribute()
{
$values = ['England', 'Scotland'];
$model = factory(Collection::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->D = $values;
$this->assertEquals($values[0], $model->D[0]);
$this->assertEquals($values[1], $model->D[1]);
}
public function testDiscographyAttributeSaves()
{
$values = ['England', 'Scotland'];
$model = factory(Collection::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->D = $values;
$model->save();
$model = $model->fresh();
$this->assertEquals($values[0], $model->D[0]);
$this->assertEquals($values[1], $model->D[1]);
}
public function testCanGetRhythmAttribute()
{
$string = 'Arthur';
$model = factory(Collection::class)->create([]);
$attr = factory(CollectionAttribute::class)->create([
'collection_id' => $model->id,
'type' => 'Rhythm',
'string' => $string,
]);
$model = $model->fresh();
$this->assertInstanceOf(Collection::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($string, $model->R[0]);
}
public function testSetRhythmAttribute()
{
$values = ['England', 'Scotland'];
$model = factory(Collection::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->R = $values;
$this->assertEquals($values[0], $model->R[0]);
$this->assertEquals($values[1], $model->R[1]);
}
public function testRhythmAttributeSaves()
{
$values = ['England', 'Scotland'];
$model = factory(Collection::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->R = $values;
$model->save();
$model = $model->fresh();
$this->assertEquals($values[0], $model->R[0]);
$this->assertEquals($values[1], $model->R[1]);
}
public function testCanGetHistoryAttribute()
{
$string = 'Arthur';
$model = factory(Collection::class)->create([]);
$attr = factory(CollectionAttribute::class)->create([
'collection_id' => $model->id,
'type' => 'History',
'string' => $string,
]);
$model = $model->fresh();
$this->assertInstanceOf(Collection::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($string, $model->H[0]);
}
public function testSetHistoryAttribute()
{
$values = ['England', 'Scotland'];
$model = factory(Collection::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->H = $values;
$this->assertEquals($values[0], $model->H[0]);
$this->assertEquals($values[1], $model->H[1]);
}
public function testHistoryAttributeSaves()
{
$values = ['England', 'Scotland'];
$model = factory(Collection::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->A = $values;
$model->save();
$model = $model->fresh();
$this->assertEquals($values[0], $model->A[0]);
$this->assertEquals($values[1], $model->A[1]);
}
public function testCanGetFileAttribute()
{
$string = 'Arthur';
$model = factory(Collection::class)->create([]);
$attr = factory(CollectionAttribute::class)->create([
'collection_id' => $model->id,
'type' => 'File',
'string' => $string,
]);
$model = $model->fresh();
$this->assertInstanceOf(Collection::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($string, $model->F[0]);
}
public function testSetFileAttribute()
{
$values = ['England', 'Scotland'];
$model = factory(Collection::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->F = $values;
$this->assertEquals($values[0], $model->F[0]);
$this->assertEquals($values[1], $model->F[1]);
}
public function testFileAttributeSaves()
{
$values = ['England', 'Scotland'];
$model = factory(Collection::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->F = $values;
$model->save();
$model = $model->fresh();
$this->assertEquals($values[0], $model->F[0]);
$this->assertEquals($values[1], $model->F[1]);
}
public function testCanGetBookAttribute()
{
$string = 'Arthur';
$model = factory(Collection::class)->create([]);
$attr = factory(CollectionAttribute::class)->create([
'collection_id' => $model->id,
'type' => 'Book',
'string' => $string,
]);
$model = $model->fresh();
$this->assertInstanceOf(Collection::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($string, $model->B[0]);
}
public function testSetBookAttribute()
{
$values = ['England', 'Scotland'];
$model = factory(Collection::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->B = $values;
$this->assertEquals($values[0], $model->B[0]);
$this->assertEquals($values[1], $model->B[1]);
}
public function testBookAttributeSaves()
{
$values = ['England', 'Scotland'];
$model = factory(Collection::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->B = $values;
$model->save();
$model = $model->fresh();
$this->assertEquals($values[0], $model->B[0]);
$this->assertEquals($values[1], $model->B[1]);
}
public function testCanGetNoteAttribute()
{
$string = 'Arthur';
$model = factory(Collection::class)->create([]);
$attr = factory(CollectionAttribute::class)->create([
'collection_id' => $model->id,
'type' => 'Note',
'string' => $string,
]);
$model = $model->fresh();
$this->assertInstanceOf(Collection::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($string, $model->N[0]);
}
public function testSetNoteAttribute()
{
$values = ['England', 'Scotland'];
$model = factory(Collection::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->N = $values;
$this->assertEquals($values[0], $model->N[0]);
$this->assertEquals($values[1], $model->N[1]);
}
public function testNoteAttributeSaves()
{
$values = ['England', 'Scotland'];
$model = factory(Collection::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->N = $values;
$model->save();
$model = $model->fresh();
$this->assertEquals($values[0], $model->N[0]);
$this->assertEquals($values[1], $model->N[1]);
}
public function testCanGetSourceAttribute()
{
$string = 'Arthur';
$model = factory(Collection::class)->create([]);
$attr = factory(CollectionAttribute::class)->create([
'collection_id' => $model->id,
'type' => 'Source',
'string' => $string,
]);
$model = $model->fresh();
$this->assertInstanceOf(Collection::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($string, $model->S[0]);
}
public function testSetSourceAttribute()
{
$values = ['England', 'Scotland'];
$model = factory(Collection::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->S = $values;
$this->assertEquals($values[0], $model->S[0]);
$this->assertEquals($values[1], $model->S[1]);
}
public function testSourceAttributeSaves()
{
$values = ['England', 'Scotland'];
$model = factory(Collection::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->S = $values;
$model->save();
$model = $model->fresh();
$this->assertEquals($values[0], $model->S[0]);
$this->assertEquals($values[1], $model->S[1]);
}
public function testCanGetTranscriberAttribute()
{
$string = 'Arthur';
$model = factory(Collection::class)->create([]);
$attr = factory(CollectionAttribute::class)->create([
'collection_id' => $model->id,
'type' => 'Transcriber',
'string' => $string,
]);
$model = $model->fresh();
$this->assertInstanceOf(Collection::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($string, $model->Z[0]);
}
public function testSetTranscriberAttribute()
{
$values = ['England', 'Scotland'];
$model = factory(Collection::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->Z = $values;
$this->assertEquals($values[0], $model->Z[0]);
$this->assertEquals($values[1], $model->Z[1]);
}
public function testTranscriberAttributeSaves()
{
$values = ['England', 'Scotland'];
$model = factory(Collection::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->Z = $values;
$model->save();
$model = $model->fresh();
$this->assertEquals($values[0], $model->Z[0]);
$this->assertEquals($values[1], $model->Z[1]);
}
}

View File

@@ -1,46 +0,0 @@
<?php
namespace Tests\Laravel5;
use Codeception\TestCase\Test;
use Aedart\Testing\Laravel\Traits\TestHelperTrait;
use XaiCorp\AbcParser\Models\Laravel5\Person;
class PersonTest extends BaseDbTest
{
/**
* @var \UnitTester
*/
protected $tester;
// tests: trying to...
public function testMakeModel()
{
$name = "test1";
$model = new Person();
$model->name = $name;
$this->assertInstanceOf(Person::class, $model);
$this->assertEquals($name, $model->name);
}
public function testNameIsMassAssignable()
{
$name = "test1";
$model = Person::create([
'name' =>$name,
'email' => 'me@example.com',
]);
$this->assertInstanceOf(Person::class, $model);
$this->assertEquals($name, $model->name);
}
public function testFactorySetsName()
{
$model = factory(Person::class)->make([]);
$this->assertInstanceOf(Person::class, $model);
$this->assertNotEmpty($model->name);
}
}

View File

@@ -1,114 +0,0 @@
<?php
namespace Tests\Laravel5;
use Codeception\TestCase\Test;
use Aedart\Testing\Laravel\Traits\TestHelperTrait;
use Webpatser\Uuid\Uuid;
use XaiCorp\AbcParser\Models\Laravel5\Person;
use XaiCorp\AbcParser\Models\Laravel5\Tune;
use XaiCorp\AbcParser\Models\Laravel5\TuneAttribute;
class TuneAttributeTest extends BaseDbTest
{
/**
* @var \UnitTester
*/
protected $tester;
// tests: trying to...
public function testMakeModel()
{
$tune = factory(Tune::class)->create();
$type = 'Title';
$title = 'a title';
$ordering = 1;
$model = new TuneAttribute();
$model->tune_id = $tune->id;
$model->type = $type;
$model->string = $title;
$model->ordering = $ordering;
$this->assertInstanceOf(TuneAttribute::class, $model);
$this->assertEquals($tune->id, $model->tune_id);
$this->assertEquals($type, $model->type);
$this->assertEquals($title, $model->string);
$this->assertEquals($ordering, $model->ordering);
}
public function testMassAssignable()
{
$tune = factory(Tune::class)->create();
$type = 'Title';
$title = 'a title';
$ordering = 1;
$model = TuneAttribute::create([
'tune_id' => $tune->id,
'type' => $type,
'string' => $title,
'ordering' => $ordering
]);
$this->assertInstanceOf(TuneAttribute::class, $model);
$this->assertEquals($tune->id, $model->tune_id);
$this->assertEquals($type, $model->type);
$this->assertEquals($title, $model->string);
$this->assertEquals($ordering, $model->ordering);
}
public function testFactory()
{
$model = factory(TuneAttribute::class)->make([]);
$this->assertInstanceOf(TuneAttribute::class, $model);
$this->assertNotNull($model->tune_id);
$this->assertNotNull($model->type);
$this->assertNotNull($model->string);
$this->assertNotNull($model->ordering);
$this->assertTrue($model->save(), json_encode($model->getMessages()));
}
public function testValidationAppliedOnSave()
{
$model = factory(TuneAttribute::class)->make([]);
$model->type = 'NotType';
$this->assertFalse($model->save());
}
public function testTypeValidation()
{
$model = factory(TuneAttribute::class)->make([]);
$model->type = 'NotType';
$this->assertFalse($model->validate());
}
public function testTuneIdValidation()
{
$model = factory(TuneAttribute::class)->make([]);
$model->tune_id = Uuid::generate(4);
$this->assertFalse($model->validate());
}
public function testStringValidation()
{
$longString = '';
for ($i=0; $i < 300; $i++) {
$longString .= 's';
}
$model = factory(TuneAttribute::class)->make([]);
$model->string = $longString;
$this->assertFalse($model->validate());
}
public function testOrderingValidation()
{
$model = factory(TuneAttribute::class)->make([]);
$model->ordering = "fourth";
$this->assertFalse($model->validate());
}
}

View File

@@ -1,114 +0,0 @@
<?php
namespace Tests\Laravel5;
use Codeception\TestCase\Test;
use Aedart\Testing\Laravel\Traits\TestHelperTrait;
use Webpatser\Uuid\Uuid;
use XaiCorp\AbcParser\Models\Laravel5\Person;
use XaiCorp\AbcParser\Models\Laravel5\TuneSetting;
use XaiCorp\AbcParser\Models\Laravel5\TuneSettingAttribute;
class TuneSettingAttributeTest extends BaseDbTest
{
/**
* @var \UnitTester
*/
protected $tester;
// tests: trying to...
public function testMakeModel()
{
$tune = factory(TuneSetting::class)->create();
$type = 'Title';
$title = 'a title';
$ordering = 1;
$model = new TuneSettingAttribute();
$model->tune_id = $tune->id;
$model->type = $type;
$model->string = $title;
$model->ordering = $ordering;
$this->assertInstanceOf(TuneSettingAttribute::class, $model);
$this->assertEquals($tune->id, $model->tune_id);
$this->assertEquals($type, $model->type);
$this->assertEquals($title, $model->string);
$this->assertEquals($ordering, $model->ordering);
}
public function testMassAssignable()
{
$setting = factory(TuneSetting::class)->create();
$type = 'Notes';
$value = 'a little note';
$ordering = 1;
$model = TuneSettingAttribute::create([
'setting_id' => $setting->id,
'type' => $type,
'string' => $value,
'ordering' => $ordering
]);
$this->assertInstanceOf(TuneSettingAttribute::class, $model);
$this->assertEquals($setting->id, $model->setting_id);
$this->assertEquals($type, $model->type);
$this->assertEquals($value, $model->string);
$this->assertEquals($ordering, $model->ordering);
}
public function testFactory()
{
$model = factory(TuneSettingAttribute::class)->make([]);
$this->assertInstanceOf(TuneSettingAttribute::class, $model);
$this->assertNotNull($model->setting_id);
$this->assertNotNull($model->type);
$this->assertNotNull($model->string);
$this->assertNotNull($model->ordering);
$this->assertTrue($model->save(), json_encode($model->getMessages()));
}
public function testValidationAppliedOnSave()
{
$model = factory(TuneSettingAttribute::class)->make([]);
$model->type = 'NotType';
$this->assertFalse($model->save());
}
public function testTypeValidation()
{
$model = factory(TuneSettingAttribute::class)->make([]);
$model->type = 'NotType';
$this->assertFalse($model->validate());
}
public function testTuneSettingIdValidation()
{
$model = factory(TuneSettingAttribute::class)->make([]);
$model->setting_id = Uuid::generate(4);
$this->assertFalse($model->validate());
}
public function testStringValidation()
{
$longString = '';
for ($i=0; $i < 300; $i++) {
$longString .= 's';
}
$model = factory(TuneSettingAttribute::class)->make([]);
$model->string = $longString;
$this->assertFalse($model->validate());
}
public function testOrderingValidation()
{
$model = factory(TuneSettingAttribute::class)->make([]);
$model->ordering = "fourth";
$this->assertFalse($model->validate());
}
}

View File

@@ -1,328 +0,0 @@
<?php
namespace Tests\Laravel5;
use Codeception\TestCase\Test;
use Aedart\Testing\Laravel\Traits\TestHelperTrait;
use XaiCorp\AbcParser\Models\Laravel5\Person;
use XaiCorp\AbcParser\Models\Laravel5\Tune;
use XaiCorp\AbcParser\Models\Laravel5\TuneAttribute;
use XaiCorp\AbcParser\Models\Laravel5\TuneSetting;
use XaiCorp\AbcParser\Models\Laravel5\TuneSettingAttribute;
class TuneSettingTest extends BaseDbTest
{
/**
* @var \UnitTester
*/
protected $tester;
// tests: trying to...
public function testMakeModel()
{
$model = new TuneSetting();
$this->assertInstanceOf(TuneSetting::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
}
public function testMassAssignable()
{
$tune = factory(Tune::class)->create();
$data = [
'tune_id' => $tune->id,
'meter' => 'C',
'keysig' => 'C',
'filename' => 'filename',
'tempo' => '1/8=200',
'L' => '1/8',
'music' => '',
'parts' => 'abcbc'
];
$model = TuneSetting::create($data);
$this->assertInstanceOf(TuneSetting::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($data['meter'], $model->meter);
$this->assertEquals($data['keysig'], $model->keysig);
$this->assertEquals($data['filename'], $model->filename);
$this->assertEquals($data['tempo'], $model->tempo);
$this->assertEquals($data['L'], $model->L);
$this->assertEquals($data['music'], $model->music);
$this->assertEquals($data['parts'], $model->parts);
}
public function testFactory()
{
$model = factory(TuneSetting::class)->make([]);
$this->assertInstanceOf(TuneSetting::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertNotNull($model->tune_id);
$this->assertNotNull($model->meter);
$this->assertNotNull($model->keysig);
}
public function testValidationAppliedOnSave()
{
$model = factory(TuneSetting::class)->make([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->meter = 'NotType';
$this->assertFalse($model->save());
}
public function testCanGetTranscriberAttribute()
{
$value = 'C';
$model = factory(TuneSetting::class)->create([]);
$attr = factory(TuneSettingAttribute::class)->create([
'setting_id' => $model->id,
'type' => 'Transcriber',
'string' => $value,
]);
$model = $model->fresh();
$this->assertInstanceOf(TuneSetting::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($value, $model->Z[0]);
}
public function testSetTranscriberAttribute()
{
$values = ['Me', 'Womble2'];
$model = factory(TuneSetting::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->Z = $values;
$this->assertEquals($values[0], $model->Z[0]);
$this->assertEquals($values[1], $model->Z[1]);
}
public function testTranscriberAttributeSaves()
{
$values = ['Me', 'Womble2'];
$model = factory(TuneSetting::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->Z = $values;
$model->save();
$model = $model->fresh();
$this->assertEquals($values[0], $model->Z[0]);
$this->assertEquals($values[1], $model->Z[1]);
}
public function testCanGetNoteAttribute()
{
$value = 'A note';
$model = factory(TuneSetting::class)->create([]);
$attr = factory(TuneSettingAttribute::class)->create([
'setting_id' => $model->id,
'type' => 'Note',
'string' => $value,
]);
$model = $model->fresh();
$this->assertInstanceOf(TuneSetting::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($value, $model->N[0]);
}
public function testSetNoteAttribute()
{
$values = ['Me', 'Womble2'];
$model = factory(TuneSetting::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->N = $values;
$this->assertEquals($values[0], $model->N[0]);
$this->assertEquals($values[1], $model->N[1]);
}
public function testNoteAttributeSaves()
{
$values = ['Me', 'Womble2'];
$model = factory(TuneSetting::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->N = $values;
$model->save();
$model = $model->fresh();
$this->assertEquals($values[0], $model->N[0]);
$this->assertEquals($values[1], $model->N[1]);
}
public function testCanGetDiscographyAttribute()
{
$value = 'A recording';
$model = factory(TuneSetting::class)->create([]);
$attr = factory(TuneSettingAttribute::class)->create([
'setting_id' => $model->id,
'type' => 'Discography',
'string' => $value,
]);
$model = $model->fresh();
$this->assertInstanceOf(TuneSetting::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($value, $model->D[0]);
}
public function testSetDiscographyAttribute()
{
$values = ['Me', 'Womble2'];
$model = factory(TuneSetting::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->D = $values;
$this->assertEquals($values[0], $model->D[0]);
$this->assertEquals($values[1], $model->D[1]);
}
public function testDiscographyAttributeSaves()
{
$values = ['Me', 'Womble2'];
$model = factory(TuneSetting::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->D = $values;
$model->save();
$model = $model->fresh();
$this->assertEquals($values[0], $model->D[0]);
$this->assertEquals($values[1], $model->D[1]);
}
public function testCanGetSourceAttribute()
{
$value = 'A feel';
$model = factory(TuneSetting::class)->create([]);
$attr = factory(TuneSettingAttribute::class)->create([
'setting_id' => $model->id,
'type' => 'Source',
'string' => $value,
]);
$model = $model->fresh();
$this->assertInstanceOf(TuneSetting::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($value, $model->S[0]);
}
public function testSetSourceAttribute()
{
$values = ['Me', 'Womble2'];
$model = factory(TuneSetting::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->S = $values;
$this->assertEquals($values[0], $model->S[0]);
$this->assertEquals($values[1], $model->S[1]);
}
public function testSourceAttributeSaves()
{
$values = ['Me', 'Womble2'];
$model = factory(TuneSetting::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->S = $values;
$model->save();
$model = $model->fresh();
$this->assertEquals($values[0], $model->S[0]);
$this->assertEquals($values[1], $model->S[1]);
}
public function testCanGetWordAttribute()
{
$value = 'A feel';
$model = factory(TuneSetting::class)->create([]);
$attr = factory(TuneSettingAttribute::class)->create([
'setting_id' => $model->id,
'type' => 'Word',
'string' => $value,
]);
$model = $model->fresh();
$this->assertInstanceOf(TuneSetting::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($value, $model->W[0]);
}
public function testSetWordAttribute()
{
$values = ['Me', 'Womble2'];
$model = factory(TuneSetting::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->W = $values;
$this->assertEquals($values[0], $model->W[0]);
$this->assertEquals($values[1], $model->W[1]);
}
public function testWordAttributeSaves()
{
$values = ['Me', 'Womble2'];
$model = factory(TuneSetting::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->W = $values;
$model->save();
$model = $model->fresh();
$this->assertEquals($values[0], $model->W[0]);
$this->assertEquals($values[1], $model->W[1]);
}
public function testCanGetBookAttribute()
{
$value = 'A feel';
$model = factory(TuneSetting::class)->create([]);
$attr = factory(TuneSettingAttribute::class)->create([
'setting_id' => $model->id,
'type' => 'Book',
'string' => $value,
]);
$model = $model->fresh();
$this->assertInstanceOf(TuneSetting::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($value, $model->B[0]);
}
public function testSetBookAttribute()
{
$values = ['Me', 'Womble2'];
$model = factory(TuneSetting::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->B = $values;
$this->assertEquals($values[0], $model->B[0]);
$this->assertEquals($values[1], $model->B[1]);
}
public function testBookAttributeSaves()
{
$values = ['Me', 'Womble2'];
$model = factory(TuneSetting::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->B = $values;
$model->save();
$model = $model->fresh();
$this->assertEquals($values[0], $model->B[0]);
$this->assertEquals($values[1], $model->B[1]);
}
}

View File

@@ -1,270 +0,0 @@
<?php
namespace Tests\Laravel5;
use Codeception\TestCase\Test;
use Aedart\Testing\Laravel\Traits\TestHelperTrait;
use XaiCorp\AbcParser\Models\Laravel5\Person;
use XaiCorp\AbcParser\Models\Laravel5\Tune;
use XaiCorp\AbcParser\Models\Laravel5\TuneAttribute;
class TuneTest extends BaseDbTest
{
/**
* @var \UnitTester
*/
protected $tester;
// tests: trying to...
public function testMakeModel()
{
$model = new Tune();
$this->assertInstanceOf(Tune::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
}
public function testMassAssignable()
{
$xId = 44;
$model = Tune::create([
'x_id' => $xId,
]);
$this->assertInstanceOf(Tune::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($xId, $model->x_id);
}
public function testFactory()
{
$model = factory(Tune::class)->make([]);
$this->assertInstanceOf(Tune::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertNotNull($model->x_id);
}
public function testCanGetTitleAttribute()
{
$title = 'Wombles Forever';
$model = factory(Tune::class)->create([]);
$attr = factory(TuneAttribute::class)->create([
'tune_id' => $model->id,
'type' => 'Title',
'string' => $title,
]);
$model = $model->fresh();
$this->assertInstanceOf(Tune::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($title, $model->T[0]);
}
public function testSetTitleAttribute()
{
$titles = ['Title1', 'Womble2'];
$model = factory(Tune::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->T = $titles;
$this->assertEquals($titles[0], $model->T[0]);
$this->assertEquals($titles[1], $model->T[1]);
}
public function testTitleAttributeSaves()
{
$titles = ['Title1', 'Womble2'];
$model = factory(Tune::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->T = $titles;
$model->save();
$model = $model->fresh();
$this->assertEquals($titles[0], $model->T[0]);
$this->assertEquals($titles[1], $model->T[1]);
}
public function testCanGetGroupAttribute()
{
$group = 'Flute';
$model = factory(Tune::class)->create([]);
$attr = factory(TuneAttribute::class)->create([
'tune_id' => $model->id,
'type' => 'Group',
'string' => $group,
]);
$model = $model->fresh();
$this->assertInstanceOf(Tune::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($group, $model->G[0]);
}
public function testSetGroupAttribute()
{
$groups = ['Flute', 'Oboe'];
$model = factory(Tune::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->G = $groups;
$this->assertEquals($groups[0], $model->G[0]);
$this->assertEquals($groups[1], $model->G[1]);
}
public function testGroupAttributeSaves()
{
$groups = ['Flute', 'Oboe'];
$model = factory(Tune::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->G = $groups;
$model->save();
$model = $model->fresh();
$this->assertEquals($groups[0], $model->G[0]);
$this->assertEquals($groups[1], $model->G[1]);
}
public function testCanGetOriginAttribute()
{
$origin = 'England';
$model = factory(Tune::class)->create([]);
$attr = factory(TuneAttribute::class)->create([
'tune_id' => $model->id,
'type' => 'Origin',
'string' => $origin,
]);
$model = $model->fresh();
$this->assertInstanceOf(Tune::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($origin, $model->O[0]);
}
public function testSetOriginAttribute()
{
$origins = ['England', 'Scotland'];
$model = factory(Tune::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->O = $origins;
$this->assertEquals($origins[0], $model->O[0]);
$this->assertEquals($origins[1], $model->O[1]);
}
public function testOriginAttributeSaves()
{
$origins = ['England', 'Scotland'];
$model = factory(Tune::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->O = $origins;
$model->save();
$model = $model->fresh();
$this->assertEquals($origins[0], $model->O[0]);
$this->assertEquals($origins[1], $model->O[1]);
}
public function testCanGetRhythmAttribute()
{
$rhythm = 'Reel';
$model = factory(Tune::class)->create([]);
$attr = factory(TuneAttribute::class)->create([
'tune_id' => $model->id,
'type' => 'Rhythm',
'string' => $rhythm,
]);
$model = $model->fresh();
$this->assertInstanceOf(Tune::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($rhythm, $model->R[0]);
}
public function testSetRhythmAttribute()
{
$rhythms = ['Reel', 'March'];
$model = factory(Tune::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->R = $rhythms;
$this->assertEquals($rhythms[0], $model->R[0]);
$this->assertEquals($rhythms[1], $model->R[1]);
}
public function testRhythmAttributeSaves()
{
$rhythms = ['England', 'Scotland'];
$model = factory(Tune::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->R = $rhythms;
$model->save();
$model = $model->fresh();
$this->assertEquals($rhythms[0], $model->R[0]);
$this->assertEquals($rhythms[1], $model->R[1]);
}
public function testCanGetHistoryAttribute()
{
$history = 'England';
$model = factory(Tune::class)->create([]);
$attr = factory(TuneAttribute::class)->create([
'tune_id' => $model->id,
'type' => 'History',
'string' => $history,
]);
$model = $model->fresh();
$this->assertInstanceOf(Tune::class, $model);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$this->assertEquals($history, $model->H[0]);
}
public function testSetHistoryAttribute()
{
$history = ['some ', 'lines'];
$model = factory(Tune::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->H = $history;
$this->assertEquals($history[0], $model->H[0]);
$this->assertEquals($history[1], $model->H[1]);
}
public function testHistoryAttributeSaved()
{
$history = ['some ', 'lines'];
$model = factory(Tune::class)->create([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->H = $history;
$model->save();
$model = $model->fresh();
$this->assertEquals($history[0], $model->H[0]);
$this->assertEquals($history[1], $model->H[1]);
}
public function testValidationAppliedOnSave()
{
$model = factory(Tune::class)->make([]);
$this->assertEmpty($model->getMessages(), json_encode($model->getMessages()));
$model->x_id = 'NotType';
$this->assertFalse($model->save());
}
}

View File

@@ -1,56 +0,0 @@
<?php
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
$factory->define(\XaiCorp\AbcParser\Models\Laravel5\Collection::class, function (Faker\Generator $faker) {
return [
'name' => $faker->name,
];
});
$factory->define(\XaiCorp\AbcParser\Models\Laravel5\Tune::class, function (Faker\Generator $faker) {
return [
'x_id' => $faker->numberBetween(1, 10),
];
});
$factory->define(\XaiCorp\AbcParser\Models\Laravel5\Person::class, function (Faker\Generator $faker) {
return [
'name' => $faker->name,
'email'=> $faker->safeEmail,
];
});
$factory->define(\XaiCorp\AbcParser\Models\Laravel5\TuneAttribute::class, function (Faker\Generator $faker) {
$types = \XaiCorp\AbcParser\Models\Laravel5\TuneAttribute::getTypes();
return [
'tune_id' => function () {
return factory(\XaiCorp\AbcParser\Models\Laravel5\Tune::class)->create()->id;
},
'type' => $types[random_int(0, count($types)-1)],
'string' => $faker->words(3, true),
'ordering' => $faker->numberBetween(1, 5),
];
});
$factory->define(\XaiCorp\AbcParser\Models\Laravel5\CollectionAttribute::class, function (Faker\Generator $faker) {
$types = \XaiCorp\AbcParser\Models\Laravel5\CollectionAttribute::getTypes();
return [
'collection_id' => function () {
return factory(\XaiCorp\AbcParser\Models\Laravel5\Collection::class)->create()->id;
},
'type' => $types[random_int(0, count($types)-1)],
'string' => $faker->words(3, true),
'ordering' => $faker->numberBetween(1, 5),
];
});

View File

@@ -1,24 +0,0 @@
<?php
$factory->define(\XaiCorp\AbcParser\Models\Laravel5\TuneSetting::class, function (Faker\Generator $faker) {
return [
'tune_id' => function () {
return factory(\XaiCorp\AbcParser\Models\Laravel5\Tune::class)->create()->id;
},
'meter' => 'C',
'keysig' => '6/8',
];
});
$factory->define(\XaiCorp\AbcParser\Models\Laravel5\TuneSettingAttribute::class, function (Faker\Generator $faker) {
$types = \XaiCorp\AbcParser\Models\Laravel5\TuneSettingAttribute::getTypes();
return [
'setting_id' => function () {
return factory(\XaiCorp\AbcParser\Models\Laravel5\TuneSetting::class)->create()->id;
},
'type' => $types[random_int(0, count($types)-1)],
'string' => $faker->words(3, true),
'ordering' => $faker->numberBetween(1, 5),
];
});

View File

@@ -1,10 +1,12 @@
<?php <?php
namespace Tests\Unit;
use \UnitTester;
use \Codeception\Util\Stub; use \Codeception\Util\Stub;
use \XaiCorp\AbcParser\Parser; use \XaiCorp\AbcParser\Parser;
use \XaiCorp\AbcParser\Interfaces\Builder; use \XaiCorp\AbcParser\Interfaces\Builder;
class AbcParserCest class ParserCest
{ {
/** /**
* @var \XaiCorp\AbcParser\Interfaces\Builder * @var \XaiCorp\AbcParser\Interfaces\Builder
@@ -62,6 +64,7 @@ class AbcParserCest
->shouldReceive('newTune')->once() ->shouldReceive('newTune')->once()
->shouldReceive('newSetting')->once() ->shouldReceive('newSetting')->once()
->shouldReceive('appendToSetting')->once() ->shouldReceive('appendToSetting')->once()
->shouldReceive('setOnSetting')->once()
->shouldReceive('storeTune')->once() ->shouldReceive('storeTune')->once()
->shouldreceive('getCollection')->once()->andreturn(true); ->shouldreceive('getCollection')->once()->andreturn(true);
$builder->shouldReceive('setOnTune') $builder->shouldReceive('setOnTune')

View File

@@ -1,11 +1,12 @@
<?php <?php
namespace Tests\Laravel5;
use \UnitTester; namespace Tests\Unit\Arr;
use XaiCorp\AbcParser\Models\Laravel5\Abc;
use UnitTester;
use XaiCorp\AbcParser\Models\Arr\Abc;
use XaiCorp\AbcParser\Parser; use XaiCorp\AbcParser\Parser;
class AbcParserCest class AbcCest
{ {
/** /**
* @var string * @var string
@@ -63,15 +64,14 @@ class AbcParserCest
'X' => '3', 'X' => '3',
'M' => '4/4', 'M' => '4/4',
'K' => 'C', 'K' => 'C',
'music' => 'gaab babc :|' 'music' => 'gaab babc :|',
], ],
]; ];
$result = $parser->parseABC($abc); $result = $parser->parseABC($abc);
$I->assertNotEmpty($result); $I->assertNotEmpty($result);
$resultArray = $result->toArray(); $I->assertEquals($expected, $result);
$I->assertEquals($expected, $resultArray);
} }
public function seeParseABCExample2(UnitTester $I) public function seeParseABCExample2(UnitTester $I)
@@ -88,7 +88,7 @@ class AbcParserCest
'G' => ['lute'], 'G' => ['lute'],
'H' => [ 'H' => [
'Thousand year old tradition', 'Thousand year old tradition',
'The Horns live in the church and are removed for the dance once a year' 'The Horns live in the church and are removed for the dance once a year',
], ],
'R' => ['Jig'], 'R' => ['Jig'],
'F' => ['none.abc'], 'F' => ['none.abc'],
@@ -106,15 +106,14 @@ class AbcParserCest
'music' => 'e|B2e G2e|B2e E2G|FGA GAB|1AGF G2:|2AGF E2| 'music' => 'e|B2e G2e|B2e E2G|FGA GAB|1AGF G2:|2AGF E2|
|e|c2e cde|A2c ABc|FGA GFE|_E=EF B,2g| |e|c2e cde|A2c ABc|FGA GFE|_E=EF B,2g|
e2g efg|c2e cde|dcB AGF|E3E2 e2g efg|c2e cde|dcB AGF|E3E2
|:A|BcB e3|BcB f3|BcB AGF|1G2F G2:|2E3-E2|]' |:A|BcB e3|BcB f3|BcB AGF|1G2F G2:|2E3-E2|]',
], ],
]; ];
$result = $parser->parseABC($abc); $result = $parser->parseABC($abc);
$I->assertNotEmpty($result); $I->assertNotEmpty($result);
$resultArray = $result->toArray(); $I->assertEquals($expected, $result);
$I->assertEquals($expected, $resultArray);
} }
@@ -128,7 +127,7 @@ e2g efg|c2e cde|dcB AGF|E3E2
'D' => ['None'], 'D' => ['None'],
'H' => [ 'H' => [
'Thousand year old tradition', 'Thousand year old tradition',
'The Horns live in the church and are removed for the dance once a year' 'The Horns live in the church and are removed for the dance once a year',
], ],
'R' => ['Jig'], 'R' => ['Jig'],
'F' => ['none.abc'], 'F' => ['none.abc'],
@@ -142,16 +141,16 @@ e2g efg|c2e cde|dcB AGF|E3E2
1 => [ 1 => [
'X' => '3', 'X' => '3',
'T' => ['Short and Sweet'],
'M' => '4/4', 'M' => '4/4',
'K' => 'C', 'K' => 'C',
'music' => 'gaab babc :|' 'music' => 'gaab babc :|',
] 'T' => ['Short and Sweet']
],
]; ];
$result = $parser->parseABC($abc); $result = $parser->parseABC($abc);
$I->assertNotEmpty($result->toArray()); $I->assertNotEmpty($result);
$I->assertEquals($expected, $result->toArray()); $I->assertEquals($expected, $result);
} }
} }

View File

@@ -1,154 +0,0 @@
<?php
namespace arr;
use \UnitTester;
use XaiCorp\AbcParser\Models\Arr\Abc;
use XaiCorp\AbcParser\Parser;
class AbcParserCest
{
/**
* @var string
*/
protected $dataDir;
/**
* @var \XaiCorp\AbcParser\Interfaces\Builder
*/
protected $builder;
/**
* @var Parser;
*/
protected $parser;
public function __construct()
{
$this->dataDir = codecept_data_dir();
}
public function _before(UnitTester $I)
{
$this->builder = new Abc();
}
public function _after(UnitTester $I)
{
unset($builder);
}
// tests: trying to...
public function createParser(UnitTester $I)
{
$parser = new Parser($this->builder);
$I->assertInstanceOf(Parser::class, $parser);
}
public function seeParseEmptyAbcWithoutErrors(UnitTester $I)
{
$abc = '';
$parser = new Parser($this->builder);
$result = $parser->parseABC($abc);
$I->assertEmpty($result);
}
public function seeParseABCExample1(UnitTester $I)
{
$abc = file_get_contents($this->dataDir.'/abc/valid_abc_1.abc');
$parser = new Parser($this->builder);
$expected = [
1 => [
'X' => '3',
'M' => '4/4',
'K' => 'C',
'music' => 'gaab babc :|'
],
];
$result = $parser->parseABC($abc);
$I->assertNotEmpty($result);
$I->assertEquals($expected, $result);
}
public function seeParseABCExample2(UnitTester $I)
{
$abc = file_get_contents($this->dataDir.'/abc/valid_abc_2.abc');
$parser = new Parser($this->builder);
$expected = [
1 => [
'X' => '40',
'T' => ['Abbotts Bromley Horn Dance'],
'A' => ['trad'],
'C' => ['trad.'],
'D' => ['None'],
'G' => ['lute'],
'H' => [
'Thousand year old tradition',
'The Horns live in the church and are removed for the dance once a year'
],
'R' => ['Jig'],
'F' => ['none.abc'],
'B' => ['Traditional English tunes'],
'W' => ['None'],
'Q' => '1/8=80',
'L' => '1/8',
'M' => '6/8',
'N' => ['Traditional English'],
'O' => ['England'],
'Z' => ['Andy Hornby'],
'S' => ['http://www.leeds.ac.uk/music/Info/RRTuneBk/gettune/00000dab.html'],
'P' => 'ABC',
'K' => 'G',
'music' => 'e|B2e G2e|B2e E2G|FGA GAB|1AGF G2:|2AGF E2|
|e|c2e cde|A2c ABc|FGA GFE|_E=EF B,2g|
e2g efg|c2e cde|dcB AGF|E3E2
|:A|BcB e3|BcB f3|BcB AGF|1G2F G2:|2E3-E2|]'
],
];
$result = $parser->parseABC($abc);
$I->assertNotEmpty($result);
$I->assertEquals($expected, $result);
}
public function seeParseABCExample3(UnitTester $I)
{
$abc = file_get_contents($this->dataDir.'/abc/valid_abc_3.abc');
$parser = new Parser($this->builder);
$expected = [
'A' => ['trad'],
'C' => ['trad.'],
'D' => ['None'],
'H' => [
'Thousand year old tradition',
'The Horns live in the church and are removed for the dance once a year'
],
'R' => ['Jig'],
'F' => ['none.abc'],
'B' => ['Traditional English tunes'],
'L' => '1/8',
'M' => '6/8',
'N' => ['Traditional English'],
'O' => ['England'],
'S' => ['http://www.leeds.ac.uk/music/Info/RRTuneBk/gettune/00000dab.html'],
'Z' => ['Andy Hornby'],
1 => [
'X' => '3',
'M' => '4/4',
'K' => 'C',
'music' => 'gaab babc :|'
]
];
$result = $parser->parseABC($abc);
$I->assertNotEmpty($result);
$I->assertEquals($expected, $result);
}
}

View File

@@ -1,117 +1,54 @@
<?php <?php
namespace Tests\Unit\Memory;
/** use XaiCorp\AbcParser\Models\Memory\Abc;
* @group Lib use XaiCorp\AbcParser\Models\Memory\Person;
* @group Unit use XaiCorp\AbcParser\Parser as AbcParser;
*/
use App\Libraries\abcParse\AbcParser;
class AbcParserTest extends \Codeception\TestCase\Test class AbcParserTest extends \Codeception\TestCase\Test
{ {
private $_facade; private $facade;
private $valid_abc_1 = "
//blank first line means this isn't a file header anymore!
A: trad
B: Traditional English tunes
C: trad.
X:3
M:4/4
K:C
gaab babc :|
";
private $valid_abc_2 = "
X:40
T:Abbotts Bromley Horn Dance
A: trad
C: trad.
D: None
G:lute
H: Thousand year old tradition
The Horns live in the church and are removed for the dance once a year
R:Jig
F:none.abc
B: Traditional English tunes
W:None
Q:1/8=80
L:1/8
M:6/8
N:Traditional English
O:England
Z:Andy Hornby
%%TUNEURL: http://www.leeds.ac.uk/music/Info/RRTuneBk/gettune/00000dab.html
%%ID:00000dab
S:http://www.leeds.ac.uk/music/Info/RRTuneBk/gettune/00000dab.html
P:ABC
K:G
e|B2e G2e|B2e E2G|FGA GAB|1AGF G2:|2AGF E2|
|e|c2e cde|A2c ABc|FGA GFE|_E=EF B,2g|
e2g efg|c2e cde|dcB AGF|E3E2
|:A|BcB e3|BcB f3|BcB AGF|1G2F G2:|2E3-E2|]
";
private $valid_abc_3 = "A: trad
B: Traditional English tunes
C: trad.
D: None
F:none.abc
H: Thousand year old tradition
The Horns live in the church and are removed for the dance once a year
L:1/8
M:6/8
N:Traditional English
O:England
R:Jig
S:http://www.leeds.ac.uk/music/Info/RRTuneBk/gettune/00000dab.html
Z:Andy Hornby
X:3
M:4/4
K:C
gaab babc :|
";
public function setUp() public function setUp()
{ {
parent::setup(); parent::setup();
$this->_facade = new AbcParser(); $this->facade = new AbcParser(new Abc());
} }
public function test_not_header_data_no_crash() private function getValidAbc($filename = '/abc/valid_abc_1.abc')
{ {
$result = $this->_facade->parseABC($this->valid_abc_1); return file_get_contents(codecept_data_dir($filename));
$this->assertTrue(is_a($result, 'App\Libraries\abcParse\TuneCollection')); }
public function testNotHeaderDataNoCrash()
{
$result = $this->facade->parseABC($this->getValidAbc());
$this->assertInstanceOf(\XaiCorp\AbcParser\Models\Memory\TuneCollection::class, $result);
} }
public function test_all_parameters_for_tune() public function testAllParametersForTune()
{ {
$result = $this->_facade->parseABC($this->valid_abc_2); $result = $this->facade->parseABC($this->getValidAbc('/abc/valid_abc_2.abc'));
$this->assertTrue(is_a($result, 'App\Libraries\abcParse\TuneCollection'));
// Tune details // Tune details
$tune = $result[0]; $tune = $result[0];
// var_dump($tune); die();
$this->assertEquals('40', $result[0]->get('X')); $this->assertEquals('40', $result[0]->get('X'));
$this->assertEquals('Abbotts Bromley Horn Dance', array_shift($tune->get('T')) ); $this->assertEquals('Abbotts Bromley Horn Dance', current($tune->get('T')));
$this->assertEquals('England', array_shift($tune->get('O')) ); $this->assertEquals('England', current($tune->get('O')));
$this->assertEquals(new App\Libraries\abcParse\Person(array('name'=>'trad')), array_shift($tune->get('A')) ); $this->assertEquals(new Person(['name' => 'trad']), current($tune->get('A')));
$this->assertEquals(new App\Libraries\abcParse\Person(array('name'=>'trad.')), array_shift($tune->get('C')) ); $this->assertEquals(new Person(['name' => 'trad.']), current($tune->get('C')));
$this->assertEquals('England', array_shift($tune->get('O')) ); $this->assertEquals('England', current($tune->get('O')));
$this->assertEquals('lute', array_shift($tune->get('G')) ); $this->assertEquals('lute', current($tune->get('G')));
$history = $tune->get('H'); $history = $tune->get('H');
$this->assertEquals(2, count($history)); $this->assertEquals(2, count($history));
$this->assertEquals('Thousand year old tradition', $history[0]); $this->assertEquals('Thousand year old tradition', $history[0]);
$this->assertEquals('The Horns live in the church and are removed for the dance once a year', $history[1]); $this->assertEquals('The Horns live in the church and are removed for the dance once a year', $history[1]);
$this->assertEquals('Jig', array_shift($tune->get('R')) ); $this->assertEquals('Jig', current($tune->get('R')));
// setting details // setting details
$setting = $tune[0]; $setting = $tune[0];
// var_dump($setting);die; $this->assertEquals('Traditional English', current($setting->get('N')));
$this->assertEquals('Traditional English', array_shift($setting->get('N')) );
$this->assertEquals('1/8', $setting->get('L')); $this->assertEquals('1/8', $setting->get('L'));
$this->assertEquals('6/8', $setting->get('M')); $this->assertEquals('6/8', $setting->get('M'));
$this->assertEquals('G', $setting->get('K')); $this->assertEquals('G', $setting->get('K'));
@@ -123,36 +60,41 @@ e2g efg|c2e cde|dcB AGF|E3E2
"; ";
$this->assertEquals(trim($expectedMusic), $setting->get('music'), "music strings should match"); $this->assertEquals(trim($expectedMusic), $setting->get('music'), "music strings should match");
$Z = new App\Libraries\abcParse\Person(array('name'=>'Andy Hornby')); $Z = new Person(['name' => 'Andy Hornby']);
$this->assertEquals($Z, array_shift($setting->get('Z')) ); $this->assertEquals($Z, current($setting->get('Z')));
$this->assertEquals('None', array_shift($setting->get('D')) ); $this->assertEquals('None', current($setting->get('D')));
$this->assertEquals('http://www.leeds.ac.uk/music/Info/RRTuneBk/gettune/00000dab.html', array_shift($setting->get('S')) ); $this->assertEquals(
$this->assertEquals('None', array_shift($setting->get('W')) ); 'http://www.leeds.ac.uk/music/Info/RRTuneBk/gettune/00000dab.html',
$this->assertEquals('Traditional English tunes', array_shift($setting->get('B')) ); current($setting->get('S'))
$this->assertEquals('none.abc', array_shift($setting->get('F')) ); );
$this->assertEquals('None', current($setting->get('W')));
$this->assertEquals('Traditional English tunes', current($setting->get('B')));
$this->assertEquals('none.abc', current($setting->get('F')));
$this->assertEquals('ABC', $setting->get('P')); $this->assertEquals('ABC', $setting->get('P'));
$this->assertEquals('1/8=80', $setting->get('Q')); $this->assertEquals('1/8=80', $setting->get('Q'));
} }
public function test_all_parameters_for_collection() public function testAllParametersForCollection()
{ {
$collection = $this->_facade->parseABC($this->valid_abc_3); $collection = $this->facade->parseABC($this->getValidAbc('/abc/valid_abc_3.abc'));
$this->assertTrue(is_a($collection, 'App\Libraries\abcParse\TuneCollection'));
$this->assertEquals(new App\Libraries\abcParse\Person(array('name'=>'trad')), array_shift($collection->get('A')) ); $this->assertEquals(new Person(['name' => 'trad']), current($collection->get('A')));
$this->assertEquals('Traditional English tunes', array_shift($collection->get('B')) ); $this->assertEquals('Traditional English tunes', current($collection->get('B')));
$this->assertEquals(new App\Libraries\abcParse\Person(array('name'=>'trad.')), array_shift($collection->get('C')) ); $this->assertEquals(new Person(['name' => 'trad.']), current($collection->get('C')));
$this->assertEquals('None', array_shift($collection->get('D')) ); $this->assertEquals('None', current($collection->get('D')));
$this->assertEquals('none.abc', array_shift($collection->get('F')) ); $this->assertEquals('none.abc', current($collection->get('F')));
$this->assertEquals('Thousand year old tradition', array_shift($collection->get('H')) ); $this->assertEquals('Thousand year old tradition', current($collection->get('H')));
$this->assertEquals('1/8', $collection->get('L')); $this->assertEquals('1/8', $collection->get('L'));
$this->assertEquals('6/8', $collection->get('M')); $this->assertEquals('6/8', $collection->get('M'));
$this->assertEquals('Traditional English', array_shift($collection->get('N')) ); $this->assertEquals('Traditional English', current($collection->get('N')));
$this->assertEquals('England', array_shift($collection->get('O')) ); $this->assertEquals('England', current($collection->get('O')));
$this->assertEquals('Jig', $collection->get('R')); $this->assertEquals('Jig', $collection->get('R'));
$this->assertEquals('http://www.leeds.ac.uk/music/Info/RRTuneBk/gettune/00000dab.html', array_shift($collection->get('S')) ); $this->assertEquals(
$this->assertEquals(new App\Libraries\abcParse\Person(array('name'=>'Andy Hornby')), array_shift($collection->get('Z')) ); 'http://www.leeds.ac.uk/music/Info/RRTuneBk/gettune/00000dab.html',
current($collection->get('S'))
);
$this->assertEquals(new Person(['name' => 'Andy Hornby']), current($collection->get('Z')));
} }
} }

View File

@@ -1,104 +0,0 @@
<?php
/**
* @group Lib
* @group Unit
*/
use App\Libraries\abcParse\Pabc;
use App\Models\abcParse\Tune;
use App\Models\abcParse\TuneSetting as Setting;
use App\Models\abcParse\Person;
use App\Libraries\abcParse\TuneCollection;
class PabcTest extends \Codeception\TestCase\Test
{
private $_facade;
public function setUp()
{
$this->_facade = new Pabc();
}
private $valid_abc_1 = "
X:1
M:C
K:C
gaab babc :|
";
/**
* test the parse_abc function
*
* This method receives abc in a string
* and converts it into a Tune object.
* If the string is not valid abc no Tune object is created
* and the method returns false.
*
* @dataProvider provider_parse_abc
*/
public function test_parse_abc($string, $isValid)
{
$result = $this->_facade->parse_abc($string);
$this->assertEquals($isValid, is_a($result, TuneCollection::class));
}
public function provider_parse_abc()
{
return array(
array('not an abc', FALSE),
array($this->valid_abc_1, TRUE),
);
}
public function test_load_models()
{
$params = array(
'tuneModel' => new Tune(),
'settingModel' => new Setting(),
'personModel' => new Person(),
);
$this->_facade = new Pabc($params);
$this->assertInstanceOf(Tune::class, $this->_facade->tuneModel);
$this->assertInstanceOf(Setting::class, $this->_facade->settingModel);
$this->assertInstanceOf(Person::class, $this->_facade->personModel);
}
public function test_save_no_models()
{
$this->assertNull($this->_facade->tuneModel);
$result = $this->_facade->parse_abc($this->valid_abc_1);
$this->assertInstanceOf(TuneCollection::class, $result);
$this->assertFalse($result->get('change_hash'));
$saved = $this->_facade->save_collection($result);
$this->assertFalse($saved);
$this->assertFalse($result->get('change_hash'));
}
public function test_save()
{
$params = array(
'tuneModel' => Mockery::mock(Tune::Class, ['store'=>true]),
'settingModel' => Mockery::mock(Setting::class, ['store'=>true]),
'personModel' => Mockery::mock(Person::class, ['store'=>true]),
);
$this->_facade = new Pabc($params);
$result = $this->_facade->parse_abc($this->valid_abc_1);
$this->assertInstanceOf(TuneCollection::class, $result);
$this->assertFalse($result->get('change_hash'));
$saved = $this->_facade->save_collection($result);
$this->assertTrue($saved);
$this->assertNotNull($result->get('change_hash'));
}
}

View File

@@ -1,40 +1,44 @@
<?php <?php
/** namespace Tests\Unit\Memory;
* @group Lib
* @group Unit
*/
use App\Libraries\abcParse\Person; use Codeception\TestCase\Test;
use \Codeception\TestCase\Test; use XaiCorp\AbcParser\Models\Memory\Person;
class PersonTest extends Test class PersonTest extends Test
{ {
private $_person; private $person;
public function setUp() public function setUp()
{ {
$this->_person = new Person(); $this->person = new Person();
} }
/** /**
* test the model contains the correct attributes * test the model contains the correct attributes
*/ */
public function test_model_definition() public function testModelDefinition()
{ {
$this->assertClassHasAttribute('person_id', Person::class); $this->assertClassHasAttribute('person_id', Person::class);
$this->assertClassHasAttribute('name', Person::class); $this->assertClassHasAttribute('name', Person::class);
$this->assertClassHasAttribute('email', Person::class); $this->assertClassHasAttribute('email', Person::class);
} }
public function test_construct() public function testConstruct()
{ {
$params = array('person_id' => 5); $params = ['person_id' => 5];
$this->_person = new Person($params); $this->person = new Person($params);
$this->assertEquals(5, $this->_person->get('person_id')); $this->assertEquals(5, $this->person->get('person_id'));
} }
/**
* @dataProvider providerSet
*/
public function testMagicSet($property, $value, $expected)
{
$this->testSet($property, $value, $expected);
}
/** /**
* test the set property method * test the set property method
@@ -43,68 +47,59 @@ class PersonTest extends Test
* @param (mixed) value to set * @param (mixed) value to set
* @param (Boolean) expected value for return value of set method * @param (Boolean) expected value for return value of set method
* *
* @dataProvider provider_set * @dataProvider providerSet
*/ */
public function test_set($property, $value, $expected) public function testSet($property, $value, $expected)
{ {
$success = $this->_person->set($property, $value); $success = $this->person->set($property, $value);
$this->assertEquals($expected, $success); $this->assertEquals($expected, $success);
if($success) if ($success) {
{ $this->assertEquals($value, $this->person->get($property));
$this->assertEquals($value, $this->_person->get($property));
} }
} }
public function providerSet()
{
return [
['Y', 'anything', false],
['person_id', 'not', false],
['person_id', 11, true],
['person_id', '11', true],
['name', null, false],
['name', 1, false],
['name', 'anything', true],
['email', 'anything', false],
['email', 1, false],
['email', 'mail@example.com', true],
];
}
/** /**
* @dataProvider provider_set * @dataProvider providerPersonGet
*/ */
public function test_magic_set($property, $value, $expected) public function testPersonGet($key, $expected)
{ {
$this->test_set($property, $value, $expected); $result = $this->person->set($key, $expected);
} $result = $this->person->get($key);
public function provider_set()
{
return array(
array('Y', 'anything', FALSE),
array('person_id', 'not', FALSE),
array('person_id', 11, TRUE),
array('person_id', '11', TRUE),
array('name', null, FALSE),
array('name', 1, FALSE),
array('name', 'anything', TRUE),
array('email', 'anything', FALSE),
array('email', 1, FALSE),
array('email', 'mail@example.com', TRUE),
);
}
/**
* @dataProvider provider_person_get
*/
public function test_person_get($key, $expected)
{
$result = $this->_person->set($key, $expected);
$result = $this->_person->get($key);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
public function provider_person_get() public function providerPersonGet()
{ {
return array( return [
array('', FALSE), ['', false],
array('me', FALSE), ['me', false],
array(array('of','me'), FALSE), [['of', 'me'], false],
array(new Person(), FALSE), [new Person(), false],
array('name', 'Richard Morgan'), ['name', 'Richard Morgan'],
array('email', 'r_morgan@sympatico.ca'), ['email', 'r_morgan@sympatico.ca'],
array('person_id', 0) ['person_id', 0],
); ];
} }
public function test_is_changed() public function testIsChanged()
{ {
$person = new Person(array('name'=>'Richard Morgan')); $person = new Person(['name' => 'Richard Morgan']);
$this->assertInstanceOf(Person::class, $person); $this->assertInstanceOf(Person::class, $person);
@@ -122,23 +117,18 @@ class PersonTest extends Test
* @param (array) $params list of properties to set on the objects * @param (array) $params list of properties to set on the objects
* @param (boolean) $expected result of running equals * @param (boolean) $expected result of running equals
* *
* @dataProvider provider_equals * @dataProvider providerEquals
*/ */
public function test_equals($params) public function testEquals($params)
{ {
// $this->markTestIncomplete();
$ob1 = new Person(); $ob1 = new Person();
$ob2 = new Person(); $ob2 = new Person();
foreach($params as $key => $val) foreach ($params as $key => $val) {
{ if (is_array($ob1->get($key))) {
if(is_array($ob1->get($key)))
{
$ob1->append($key, $val); $ob1->append($key, $val);
$ob2->append($key, $val); $ob2->append($key, $val);
} } else {
else {
$ob1->set($key, $val); $ob1->set($key, $val);
$ob2->set($key, $val); $ob2->set($key, $val);
} }
@@ -146,6 +136,7 @@ class PersonTest extends Test
$this->assertTrue(Person::equals($ob1, $ob2)); $this->assertTrue(Person::equals($ob1, $ob2));
} }
/** /**
* test the static function equals * test the static function equals
* returns true if the data properties of 2 Person objects * returns true if the data properties of 2 Person objects
@@ -154,21 +145,18 @@ class PersonTest extends Test
* @param (array) $params list of properties to set on the objects * @param (array) $params list of properties to set on the objects
* @param (boolean) $expected result of running equals * @param (boolean) $expected result of running equals
* *
* @dataProvider provider_equals * @dataProvider providerEquals
*/ */
public function test_equals_fails($params) public function testEqualsFails($params)
{ {
$ob1 = new Person(); $ob1 = new Person();
$ob2 = new Person(); $ob2 = new Person();
foreach($params as $key => $val) foreach ($params as $key => $val) {
{ if (is_array($ob1->get($key))) {
if(is_array($ob1->get($key)))
{
$ob1->append($key, $val); $ob1->append($key, $val);
$ob2->append($key, $val . " hello"); $ob2->append($key, $val . " hello");
} } else {
else {
$ob1->set($key, $val); $ob1->set($key, $val);
$ob2->set($key, $val + 1); $ob2->set($key, $val + 1);
} }
@@ -176,14 +164,13 @@ class PersonTest extends Test
// print_r($ob1); print_r($ob2); die; // print_r($ob1); print_r($ob2); die;
$this->assertFalse(Person::equals($ob1, $ob2)); $this->assertFalse(Person::equals($ob1, $ob2));
} }
public function provider_equals()
public function providerEquals()
{ {
return array( return [
// array( array('person_id'=>'2') ), // array( array('person_id'=>'2') ),
array( array('name'=>'a title') ), [['name' => 'a title']],
array( array('email'=>'mail@example.com') ), [['email' => 'mail@example.com']],
); ];
} }
} }

View File

@@ -1,26 +1,26 @@
<?php <?php
namespace Tests\Unit\Memory;
use App\Libraries\abcParse\Setting; use Codeception\TestCase\Test as TestCase;
use App\Libraries\abcParse\Person; use XaiCorp\AbcParser\Models\Memory\Person;
use \Codeception\TestCase\Test as TestCase; use XaiCorp\AbcParser\Models\Memory\Setting;
/** /**
* @group Lib * @group Lib
*/ */
class SettingTest extends TestCase class SettingTest extends TestCase
{ {
private $_setting; private $setting;
public function setUp() public function setUp()
{ {
$this->_setting = new Setting(); $this->setting = new Setting();
} }
/** /**
* test the model contains the correct attributes * test the model contains the correct attributes
*/ */
public function test_model_definition() public function testModelDefinition()
{ {
$this->assertClassHasAttribute('settingID', Setting::class); $this->assertClassHasAttribute('settingID', Setting::class);
$this->assertClassHasAttribute('tuneID', Setting::class); $this->assertClassHasAttribute('tuneID', Setting::class);
@@ -53,79 +53,79 @@ class SettingTest extends TestCase
* @param (mixed) value to set * @param (mixed) value to set
* @param (Boolean) expected value for return value of set method * @param (Boolean) expected value for return value of set method
* *
* @dataProvider provider_set * @dataProvider providerSet
*/ */
public function test_set($property, $value, $expected_success, $expected_value = FALSE) public function testSet($property, $value, $expected_success, $expected_value = false)
{ {
$success = $this->_setting->set($property, $value); $success = $this->setting->set($property, $value);
$this->assertEquals($expected_success, $success); $this->assertEquals($expected_success, $success);
if($success) if ($success) {
{ if (!$expected_value) {
if(! $expected_value ) { $expected_value = $value; } $expected_value = $value;
$this->assertEquals($expected_value, $this->_setting->get($property)); }
$this->assertEquals($expected_value, $this->setting->get($property));
} }
} }
/** /**
* @dataProvider provider_set * @dataProvider providerSet
*/ */
public function test_magic_set($property, $value, $expected_success, $expected_value = FALSE) public function testMagicSet($property, $value, $expected_success, $expected_value = false)
{ {
$this->_setting->$property = $value; $this->setting->$property = $value;
if($expected_success) if ($expected_success) {
{ $this->assertEquals($value, $this->setting->get($property));
$this->assertEquals($value, $this->_setting->get($property));
} }
} }
public function provider_set() public function providerSet()
{ {
return array( return [
array('Y', 'anything', FALSE), ['Y', 'anything', false],
array('settingID', 1, TRUE), ['settingID', 1, true],
array('tuneID', array('alpha'), FALSE), ['tuneID', ['alpha'], false],
array('tuneID', 'alpha', FALSE), ['tuneID', 'alpha', false],
array('tuneID', '1', TRUE), ['tuneID', '1', true],
array('tuneID', 1, TRUE), ['tuneID', 1, true],
array('f', 1, FALSE), ['f', 1, false],
array('F', 1, FALSE), ['F', 1, false],
array('F', '1',FALSE), ['F', '1', false],
array('F', array('aplha'), TRUE), ['F', ['aplha'], true],
array('P', array('string'), FALSE), ['P', ['string'], false],
array('P', 10, FALSE), ['P', 10, false],
array('P', 'string', TRUE), ['P', 'string', true],
array('Q', array('string'), FALSE), ['Q', ['string'], false],
array('Q', 10, FALSE), ['Q', 10, false],
array('Q', 'string', FALSE), ['Q', 'string', false],
array('Q', '1/8=200', TRUE), ['Q', '1/8=200', true],
array('L', array('string'), FALSE), ['L', ['string'], false],
array('L', 10, FALSE), ['L', 10, false],
array('L', 'string', FALSE), ['L', 'string', false],
array('L', '1/8', TRUE), ['L', '1/8', true],
array('M', array('string'), FALSE), ['M', ['string'], false],
array('M', 10, FALSE), ['M', 10, false],
array('M', 'string', FALSE), ['M', 'string', false],
array('M', '6/8', TRUE), ['M', '6/8', true],
array('M', 'C', TRUE), ['M', 'C', true],
array('M', 'c', TRUE), ['M', 'c', true],
array('M', 'C|', TRUE), ['M', 'C|', true],
array('K', array('string'), FALSE), ['K', ['string'], false],
array('K', 10, FALSE), ['K', 10, false],
array('K', 'C', TRUE), ['K', 'C', true],
array('K', 'Am', TRUE), ['K', 'Am', true],
array('K', 'A minor', TRUE), ['K', 'A minor', true],
array('K', 'E dorian', TRUE), ['K', 'E dorian', true],
array('music', 'GABc:|\\', TRUE), ['music', 'GABc:|\\', true],
['Z', new Person(), false],
array('Z', new Person(), FALSE), ['Z', [new Person(), 'not a person'], false],
array('Z', array(new Person(), 'not a person'), FALSE), ['Z', [new Person()], true],
array('Z', array(new Person()), TRUE), ['Z', 111, false],
array('Z', 111, FALSE), ['N', ['a string'], true],
array('N', array('a string'), TRUE), ['D', ['a string'], true],
array('D', array('a string'), TRUE), ['S', ['a string'], true],
array('S', array('a string'), TRUE), ['W', ['a string'], true],
array('W', array('a string'), TRUE), ['B', ['a string'], true],
array('B', array('a string'), TRUE), ];
);
} }
/** /**
@@ -133,12 +133,12 @@ class SettingTest extends TestCase
* this ensures that we can't change a setting's id once it's set. * this ensures that we can't change a setting's id once it's set.
* the default, unset value for settingID is 0 * the default, unset value for settingID is 0
*/ */
public function test_set_settingID() public function testSetSettingID()
{ {
$success = $this->_setting->set('settingID', 1); $success = $this->setting->set('settingID', 1);
$this->assertTrue($success, 'first attempt should succeed'); $this->assertTrue($success, 'first attempt should succeed');
$success = $this->_setting->set('settingID', 2); $success = $this->setting->set('settingID', 2);
$this->assertFalse($success, 'second attempt should fail'); $this->assertFalse($success, 'second attempt should fail');
} }
@@ -150,103 +150,102 @@ class SettingTest extends TestCase
* @param (mixed) value to append * @param (mixed) value to append
* @param (Boolean) expected value for return value of append method * @param (Boolean) expected value for return value of append method
* *
* @dataProvider provider_append * @dataProvider providerAppend
*/ */
public function test_append($property, $value, $expected) public function testAppend($property, $value, $expected)
{ {
$success = $this->_setting->append($property, $value); $success = $this->setting->append($property, $value);
$this->assertEquals($expected, $success); $this->assertEquals($expected, $success);
if($success) if ($success) {
{ $this->assertContains($value, $this->setting->get($property));
$this->assertContains($value, $this->_setting->get($property));
} }
} }
public function provider_append() public function providerAppend()
{ {
return array( return [
array('Y', 'anything', FALSE), ['Y', 'anything', false],
array('settingID', 1, FALSE), ['settingID', 1, false],
array('tuneID', array('alpha'), FALSE), ['tuneID', ['alpha'], false],
array('tuneID', 'alpha', FALSE), ['tuneID', 'alpha', false],
array('tuneID', '1', FALSE), ['tuneID', '1', false],
array('tuneID', 1, FALSE), ['tuneID', 1, false],
array('f', 1, FALSE), ['f', 1, false],
array('F', 1, TRUE), ['F', 1, true],
array('F', '1', TRUE), ['F', '1', true],
array('F', array('aplha'), FALSE), ['F', ['aplha'], false],
array('P', array('string'), FALSE), ['P', ['string'], false],
array('P', 10, FALSE), ['P', 10, false],
array('P', 'string', FALSE), ['P', 'string', false],
array('Q', array('string'), FALSE), ['Q', ['string'], false],
array('Q', 10, FALSE), ['Q', 10, false],
array('Q', 'string', FALSE), ['Q', 'string', false],
array('Q', '1/8=200', FALSE), ['Q', '1/8=200', false],
array('L', array('string'), FALSE), ['L', ['string'], false],
array('L', 10, FALSE), ['L', 10, false],
array('L', 'string', FALSE), ['L', 'string', false],
array('L', '1/8', FALSE), ['L', '1/8', false],
array('M', array('string'), FALSE), ['M', ['string'], false],
array('M', 10, FALSE), ['M', 10, false],
array('M', 'string', FALSE), ['M', 'string', false],
array('M', '6/8', FALSE), ['M', '6/8', false],
array('M', 'C', FALSE), ['M', 'C', false],
array('M', 'c', FALSE), ['M', 'c', false],
array('M', 'C|', FALSE), ['M', 'C|', false],
array('K', array('string'), FALSE), ['K', ['string'], false],
array('K', 10, FALSE), ['K', 10, false],
array('K', 'C', FALSE), ['K', 'C', false],
array('K', 'Am', FALSE), ['K', 'Am', false],
array('K', 'A minor', FALSE), ['K', 'A minor', false],
array('K', 'E dorian', FALSE), ['K', 'E dorian', false],
array('music', 'GABc:|\\', FALSE), ['music', 'GABc:|\\', false],
array('Z', new Person(), TRUE), ['Z', new Person(), true],
array('Z', array(new Person()), FALSE), ['Z', [new Person()], false],
array('Z', 111, FALSE), ['Z', 111, false],
array('N', array('a string'), FALSE), ['N', ['a string'], false],
array('D', array('a string'), FALSE), ['D', ['a string'], false],
array('S', array('a string'), FALSE), ['S', ['a string'], false],
array('W', array('a string'), FALSE), ['W', ['a string'], false],
array('B', array('a string'), FALSE), ['B', ['a string'], false],
array('N', 'more notes', TRUE), ['N', 'more notes', true],
array('D', 'another record', TRUE), ['D', 'another record', true],
array('S', 'another source', TRUE), ['S', 'another source', true],
array('W', 'words', TRUE), ['W', 'words', true],
array('B', 'another book', TRUE), ['B', 'another book', true],
); ];
} }
/** /**
* @dataProvider provider_get * @dataProvider providerGet
*/ */
public function test_get($key, $expected) public function testGet($key, $expected)
{ {
$result = $this->_setting->set($key, $expected); $result = $this->setting->set($key, $expected);
$result = $this->_setting->get($key); $result = $this->setting->get($key);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
public function provider_get() public function providerGet()
{ {
return array( return [
array('', FALSE), ['', false],
array('me', FALSE), ['me', false],
array('settingID', 1), ['settingID', 1],
array('tuneID', 2), ['tuneID', 2],
array('Q', '1/8=100'), ['Q', '1/8=100'],
array('L', '1/8'), ['L', '1/8'],
array('M', '6/8'), ['M', '6/8'],
array('K', 'Am'), ['K', 'Am'],
array('music', 'GABc:|\\'), ['music', 'GABc:|\\'],
array('Z', array(new Person())), ['Z', [new Person()]],
array('N', array('a string')), ['N', ['a string']],
array('D', array('a string')), ['D', ['a string']],
array('S', array('a string')), ['S', ['a string']],
array('W', array('a string')), ['W', ['a string']],
array('B', array('a string')), ['B', ['a string']],
); ];
} }
/** /**
@@ -257,23 +256,18 @@ class SettingTest extends TestCase
* @param (array) $params list of properties to set on the objects * @param (array) $params list of properties to set on the objects
* @param (boolean) $expected result of running equals * @param (boolean) $expected result of running equals
* *
* @dataProvider provider_equals * @dataProvider providerEquals
*/ */
public function test_equals($params) public function testEquals($params)
{ {
// $this->markTestIncomplete();
$ob1 = new Setting(); $ob1 = new Setting();
$ob2 = new Setting(); $ob2 = new Setting();
foreach($params as $key => $val) foreach ($params as $key => $val) {
{ if (is_array($ob1->get($key))) {
if(is_array($ob1->get($key)))
{
$ob1->append($key, $val); $ob1->append($key, $val);
$ob2->append($key, $val); $ob2->append($key, $val);
} } else {
else {
$ob1->set($key, $val); $ob1->set($key, $val);
$ob2->set($key, $val); $ob2->set($key, $val);
} }
@@ -290,49 +284,47 @@ class SettingTest extends TestCase
* @param (array) $params list of properties to set on the objects * @param (array) $params list of properties to set on the objects
* @param (boolean) $expected result of running equals * @param (boolean) $expected result of running equals
* *
* @dataProvider provider_equals * @dataProvider providerEquals
*/ */
public function test_equals_fails($params) public function testEqualsFails($params)
{ {
$ob1 = new Setting(); $ob1 = new Setting();
$ob2 = new Setting(); $ob2 = new Setting();
foreach($params as $key => $val) foreach ($params as $key => $val) {
{ if (is_array($ob1->get($key))) {
if(is_array($ob1->get($key)))
{
$ob1->append($key, $val); $ob1->append($key, $val);
// $ob2->append($key, $val); // $ob2->append($key, $val);
} } else {
else {
$ob1->set($key, $val); $ob1->set($key, $val);
$ob2->set($key, $val + 1); $ob2->set($key, $val + 1);
} }
} }
$this->assertFalse(Setting::equals($ob1, $ob2)); $this->assertFalse(Setting::equals($ob1, $ob2));
} }
public function provider_equals()
public function providerEquals()
{ {
return array( return [
array( array('settingID'=>'2') ), [['settingID' => '2']],
array( array('tuneID'=>'2') ), [['tuneID' => '2']],
array( array('Z'=> new Person()) ), [['Z' => new Person()]],
array( array('N'=>'an author') ), [['N' => 'an author']],
array( array('D'=>'a composer') ), [['D' => 'a composer']],
array( array('S'=>'a group') ), [['S' => 'a group']],
array( array('W'=>'some history') ), [['W' => 'some history']],
array( array('B'=>'Plymouth') ), [['B' => 'Plymouth']],
array( array('F'=>'Jig') ), [['F' => 'Jig']],
array( array('P'=>'ABB') ), [['P' => 'ABB']],
array( array('Q'=>'1/8=100') ), [['Q' => '1/8=100']],
array( array('L'=>'1/4') ), [['L' => '1/4']],
array( array('M'=>'2/4') ), [['M' => '2/4']],
array( array('K'=>'G') ), [['K' => 'G']],
array( array('music'=>'a|cab|') ), [['music' => 'a|cab|']],
); ];
} }
public function test_isChanged() public function testIsChanged()
{ {
$setting = new Setting(); $setting = new Setting();
@@ -345,20 +337,18 @@ class SettingTest extends TestCase
} }
public function test_construct() public function testConstruct()
{ {
$params = array( $params = [
'settingID' => 3, 'settingID' => 3,
'Z' => array(new Person()), 'Z' => [new Person()],
'P' => 'ABC' 'P' => 'ABC',
); ];
$this->_setting = new Setting ($params); $this->setting = new Setting($params);
foreach($params as $key => $val) foreach ($params as $key => $val) {
{ $this->assertEquals($val, $this->setting->get($key));
$this->assertEquals($val, $this->_setting->get($key));
} }
} }
} }

View File

@@ -1,23 +1,21 @@
<?php <?php
/** namespace Tests\Unit\Memory;
* @group Lib
* @group Unit use XaiCorp\AbcParser\Models\Memory\Person;
*/ use XaiCorp\AbcParser\Models\Memory\Tune;
use XaiCorp\AbcParser\Models\Memory\TuneCollection;
use Codeception\TestCase\Test as TestCase;
use App\Libraries\abcParse\Tune;
//use App\Libraries\memory\Setting; //use App\Libraries\memory\Setting;
use App\Libraries\abcParse\Person;
use App\Libraries\abcParse\TuneCollection;
use \Codeception\TestCase\Test as TestCase;
class TuneCollectionTest extends TestCase class TuneCollectionTest extends TestCase
{ {
private $_tunes; private $tunes;
public function setUp() public function setUp()
{ {
$this->_tunes = new TuneCollection(); $this->tunes = new TuneCollection();
} }
@@ -25,25 +23,24 @@ class TuneCollectionTest extends TestCase
* test the implementation of the Iterator interface * test the implementation of the Iterator interface
* 100% coverage! ;) * 100% coverage! ;)
*/ */
public function test_iterator() public function testIterator()
{ {
$t = new Tune(); $t = new Tune();
$this->assertEquals(0, count($this->_tunes)); $this->assertEquals(0, count($this->tunes));
$this->_tunes[] = $t; $this->tunes[] = $t;
$this->_tunes->push($t); $this->tunes->push($t);
$this->assertEquals(2, count($this->_tunes)); $this->assertEquals(2, count($this->tunes));
$this->assertInstanceOf(Tune::class, $this->_tunes[0], 'first tune'); $this->assertInstanceOf(Tune::class, $this->tunes[0], 'first tune');
$this->assertInstanceOf(Tune::class, $this->_tunes[1], 'second tune'); $this->assertInstanceOf(Tune::class, $this->tunes[1], 'second tune');
foreach($this->_tunes as $key=>$val) foreach ($this->tunes as $key => $val) {
{
$this->assertInternalType('scalar', $key); $this->assertInternalType('scalar', $key);
$this->assertInstanceOf(Tune::class, $val); $this->assertInstanceOf(Tune::class, $val);
$this->assertTrue(isset($this->_tunes[$key]), 'key is set'); $this->assertTrue(isset($this->tunes[$key]), 'key is set');
unset($this->_tunes[$key]); unset($this->tunes[$key]);
$this->assertFalse(isset($this->_tunes[$key]), 'key should have been unset'); $this->assertFalse(isset($this->tunes[$key]), 'key should have been unset');
} }
} }
@@ -52,17 +49,17 @@ class TuneCollectionTest extends TestCase
* *
* tests the implementation of the Countable interface * tests the implementation of the Countable interface
*/ */
public function test_pop() public function testPop()
{ {
$this->assertEquals(0, count($this->_tunes), 'no tunes in collection to begin with'); $this->assertEquals(0, count($this->tunes), 'no tunes in collection to begin with');
$t = new Tune(); $t = new Tune();
$this->_tunes->push($t); $this->tunes->push($t);
$this->assertEquals(1, count($this->_tunes), '1 tune added to collection'); $this->assertEquals(1, count($this->tunes), '1 tune added to collection');
$result = $this->_tunes->pop(); $result = $this->tunes->pop();
$this->assertEquals(0, count($this->_tunes), 'no tunes left in collection'); $this->assertEquals(0, count($this->tunes), 'no tunes left in collection');
$this->assertInstanceOf(Tune::class, $result); $this->assertInstanceOf(Tune::class, $result);
} }
@@ -90,17 +87,17 @@ class TuneCollectionTest extends TestCase
* @param (mixed) value to set * @param (mixed) value to set
* @param (Boolean) expected value for return value of set method * @param (Boolean) expected value for return value of set method
* *
* @dataProvider provider_set * @dataProvider providerSet
*/ */
public function test_set($property, $value, $expected) public function testSet($property, $value, $expected)
{ {
$success = $this->_tunes->set($property, $value); $success = $this->tunes->set($property, $value);
$this->assertEquals($expected, $success); $this->assertEquals($expected, $success);
if($success) if ($success) {
{ $this->assertEquals($value, $this->tunes->get($property));
$this->assertEquals($value, $this->_tunes->get($property));
} }
} }
/** /**
* test the set property method * test the set property method
* *
@@ -108,58 +105,57 @@ class TuneCollectionTest extends TestCase
* @param (mixed) value to set * @param (mixed) value to set
* @param (Boolean) expected value for return value of set method * @param (Boolean) expected value for return value of set method
* *
* @dataProvider provider_set * @dataProvider providerSet
*/ */
public function test_magic_setter($property, $value, $expected) public function testMagicSetter($property, $value, $expected)
{ {
$this->_tunes->$property = $value; $this->tunes->$property = $value;
if($expected) if ($expected) {
{ $this->assertEquals($value, $this->tunes->get($property));
$this->assertEquals($value, $this->_tunes->get($property));
} }
} }
public function provider_set() public function providerSet()
{ {
return array( return [
array('Y', 'anything', FALSE), ['Y', 'anything', false],
array('A', 10, FALSE), ['A', 10, false],
array('A', array('1','2'), FALSE), ['A', ['1', '2'], false],
array('A', array(new Person(),new Person()), TRUE), ['A', [new Person(), new Person()], true],
array('C', 10, FALSE), ['C', 10, false],
array('C', array('1','2'), FALSE), ['C', ['1', '2'], false],
array('C', array(new Person(),new Person()), TRUE), ['C', [new Person(), new Person()], true],
array('H', 10, FALSE), ['H', 10, false],
array('H', array('1','2'), TRUE), ['H', ['1', '2'], true],
array('O', 10, FALSE), ['O', 10, false],
array('O', array('1','2'), TRUE), ['O', ['1', '2'], true],
array('R', 10, FALSE), ['R', 10, false],
array('R', 'reel', TRUE), ['R', 'reel', true],
array('collection', 10, FALSE), ['collection', 10, false],
array('collection', '10', FALSE), ['collection', '10', false],
array('collection', array(), FALSE), ['collection', [], false],
array('collection', array('1','2'), FALSE), ['collection', ['1', '2'], false],
array('collection', array(new Tune(), 'not a tune'), FALSE), ['collection', [new Tune(), 'not a tune'], false],
array('collection', array(new Tune()), TRUE), ['collection', [new Tune()], true],
array('tc_id', 'abc', FALSE), ['tc_id', 'abc', false],
array('tc_id', '11', TRUE), ['tc_id', '11', true],
array('tc_id', 15, TRUE), ['tc_id', 15, true],
array('cOwner', 'me', TRUE), ['cOwner', 'me', true],
); ];
} }
public function test_set_tc_id() public function testSetTcId()
{ {
//we should start with tc_id = 0 //we should start with tc_id = 0
$this->assertEquals(0, $this->_tunes->get('tc_id'), 'should start at 0'); $this->assertEquals(0, $this->tunes->get('tc_id'), 'should start at 0');
//because tc_id == 0 we can change value //because tc_id == 0 we can change value
$this->_tunes->set('tc_id', 4); $this->tunes->set('tc_id', 4);
$this->assertEquals(4, $this->_tunes->get('tc_id'), 'should have changed to 4'); $this->assertEquals(4, $this->tunes->get('tc_id'), 'should have changed to 4');
//tc_id is not 0 so we cannot change value //tc_id is not 0 so we cannot change value
$this->_tunes->set('tc_id', 11); $this->tunes->set('tc_id', 11);
$this->assertEquals(4, $this->_tunes->get('tc_id'), 'should not have changed from 4'); $this->assertEquals(4, $this->tunes->get('tc_id'), 'should not have changed from 4');
} }
@@ -170,41 +166,38 @@ class TuneCollectionTest extends TestCase
* @param (mixed) value to append * @param (mixed) value to append
* @param (Boolean) expected value for return value of append method * @param (Boolean) expected value for return value of append method
* *
* @dataProvider provider_append * @dataProvider providerAppend
*/ */
public function test_append($property, $value, $expected) public function testAppend($property, $value, $expected)
{ {
$success = $this->_tunes->append($property, $value); $success = $this->tunes->append($property, $value);
$this->assertEquals($expected, $success); $this->assertEquals($expected, $success);
if($success) if ($success) {
$this->assertContains($value, $this->tunes->get($property));
}
}
public function providerAppend()
{ {
$this->assertContains($value, $this->_tunes->get($property)); return [
} ['Y', 1, false],
} ['H', 'history', true],
['R', 'reel', true],
public function provider_append() ['r', 'reel', false],
{ ['collection', 'setting', false],
return array( ['collection', new Tune(), true],
array('Y', 1, FALSE), ['collection', [new Tune()], false],
array('H', 'history', TRUE), ];
array('R', 'reel', TRUE),
array('r', 'reel', FALSE),
array('collection', 'setting', FALSE),
array('collection', new Tune(), TRUE),
array('collection', array(new Tune()), FALSE),
);
} }
public function testGet()
public function test_get()
{ {
//R is a valid property so we should get it's value //R is a valid property so we should get it's value
$this->_tunes->set('R', 'reel'); $this->tunes->set('R', 'reel');
$this->assertEquals('reel', $this->_tunes->get('R')); $this->assertEquals('reel', $this->tunes->get('R'));
//X is not a property, so we should get FALSE //X is not a property, so we should get FALSE
$this->assertFalse($this->_tunes->get('X')); $this->assertFalse($this->tunes->get('X'));
} }
} }

View File

@@ -1,9 +1,11 @@
<?php <?php
use App\Libraries\abcParse\Tune; namespace Tests\Unit\Memory;
use App\Libraries\abcParse\Setting;
use App\Libraries\abcParse\Person; use XaiCorp\AbcParser\Models\Memory\Person;
use \Codeception\TestCase\Test as TestCase; use XaiCorp\AbcParser\Models\Memory\Setting;
use XaiCorp\AbcParser\Models\Memory\Tune;
use Codeception\TestCase\Test as TestCase;
/** /**
* @group Lib * @group Lib
@@ -11,17 +13,17 @@ use \Codeception\TestCase\Test as TestCase;
*/ */
class TuneTest extends TestCase class TuneTest extends TestCase
{ {
private $_tune; private $tune;
public function setUp() public function setUp()
{ {
$this->_tune = new Tune(); $this->tune = new Tune();
} }
/** /**
* test the model contains the correct attributes * test the model contains the correct attributes
*/ */
public function test_model_definition() public function testModelDefinition()
{ {
//Private attributes, probably shouldn't be tested //Private attributes, probably shouldn't be tested
$this->assertClassHasAttribute('tuneID', Tune::class); $this->assertClassHasAttribute('tuneID', Tune::class);
@@ -44,17 +46,17 @@ class TuneTest extends TestCase
* @param (mixed) value to set * @param (mixed) value to set
* @param (Boolean) expected value for return value of set method * @param (Boolean) expected value for return value of set method
* *
* @dataProvider provider_set * @dataProvider providerSet
*/ */
public function test_set($property, $value, $expected) public function testSet($property, $value, $expected)
{ {
$success = $this->_tune->set($property, $value); $success = $this->tune->set($property, $value);
$this->assertEquals($expected, $success); $this->assertEquals($expected, $success);
if($success) if ($success) {
{ $this->assertEquals($value, $this->tune->get($property));
$this->assertEquals($value, $this->_tune->get($property));
} }
} }
/** /**
* test the set property method * test the set property method
* *
@@ -62,84 +64,82 @@ class TuneTest extends TestCase
* @param (mixed) value to set * @param (mixed) value to set
* @param (Boolean) expected value for return value of set method * @param (Boolean) expected value for return value of set method
* *
* @dataProvider provider_set * @dataProvider providerSet
*/ */
public function test_magic_setter($property, $value, $expected) public function testMagicSetter($property, $value, $expected)
{ {
$this->_tune->$property = $value; $this->tune->$property = $value;
// $this->assertEquals($expected, $success); // $this->assertEquals($expected, $success);
if($expected) if ($expected) {
{ $this->assertEquals($value, $this->tune->get($property));
$this->assertEquals($value, $this->_tune->get($property));
} }
} }
/** /**
* @dataProvider provider_set * @dataProvider providerSet
*/ */
public function test_construct($property, $value, $expected) public function testConstruct($property, $value, $expected)
{ {
$params = array($property => $value); $params = [$property => $value];
$this->_tune = new Tune($params); $this->tune = new Tune($params);
if($expected) if ($expected) {
{ $this->assertEquals($value, $this->tune->get($property));
$this->assertEquals($value, $this->_tune->get($property));
} }
} }
public function provider_set() public function providerSet()
{ {
return array( return [
array('Y', 'anything', FALSE), ['Y', 'anything', false],
array('x', 1, FALSE), ['x', 1, false],
array('X', 1, TRUE), ['X', 1, true],
array('X', 'aplha', FALSE), ['X', 'aplha', false],
array('X', '2', TRUE), ['X', '2', true],
array('T', 'string', FALSE), ['T', 'string', false],
array('T', 10, FALSE), ['T', 10, false],
array('T', array('1','2'), TRUE), ['T', ['1', '2'], true],
array('A', 10, FALSE), ['A', 10, false],
array('A', array('1','2'), FALSE), ['A', ['1', '2'], false],
array('A', array(new Person(),new Person()), TRUE), ['A', [new Person(), new Person()], true],
array('C', 10, FALSE), ['C', 10, false],
array('C', array('1','2'), FALSE), ['C', ['1', '2'], false],
array('C', array(new Person(),new Person()), TRUE), ['C', [new Person(), new Person()], true],
array('G', 10, FALSE), ['G', 10, false],
array('G', array('1','2'), TRUE), ['G', ['1', '2'], true],
array('H', 10, FALSE), ['H', 10, false],
array('H', array('1','2'), TRUE), ['H', ['1', '2'], true],
array('O', 10, FALSE), ['O', 10, false],
array('O', array('1','2'), TRUE), ['O', ['1', '2'], true],
array('R', 10, FALSE), ['R', 10, false],
array('R', array('1','2'), TRUE), ['R', ['1', '2'], true],
array('collection', 10, FALSE), ['collection', 10, false],
array('collection', '10', FALSE), ['collection', '10', false],
array('collection', array(), FALSE), ['collection', [], false],
array('collection', array('1','2'), FALSE), ['collection', ['1', '2'], false],
array('collection', array(new Setting()), TRUE), ['collection', [new Setting()], true],
array('tuneHash', 10, FALSE), ['tuneHash', 10, false],
array('tuneHash', '10', FALSE), ['tuneHash', '10', false],
array('tuneHash', array(), FALSE), ['tuneHash', [], false],
array('tuneHash', array('1','2'), FALSE), ['tuneHash', ['1', '2'], false],
array('tuneID', 'abc', FALSE), ['tuneID', 'abc', false],
array('tuneID', '11', TRUE), ['tuneID', '11', true],
array('tuneID', 15, TRUE), ['tuneID', 15, true],
); ];
} }
public function test_set_tuneID() public function testSetTuneID()
{ {
//we should start with tuneID = 0 //we should start with tuneID = 0
$this->assertEquals(0, $this->_tune->get('tuneID'), 'should start at 0'); $this->assertEquals(0, $this->tune->get('tuneID'), 'should start at 0');
//because tuneID == 0 we can change value //because tuneID == 0 we can change value
$this->_tune->set('tuneID', 4); $this->tune->set('tuneID', 4);
$this->assertEquals(4, $this->_tune->get('tuneID'), 'should have changed to 4'); $this->assertEquals(4, $this->tune->get('tuneID'), 'should have changed to 4');
//tuneID is not 0 so we cannot change value //tuneID is not 0 so we cannot change value
$this->_tune->set('tuneID', 11); $this->tune->set('tuneID', 11);
$this->assertEquals(4, $this->_tune->get('tuneID'), 'should not have changed from 4'); $this->assertEquals(4, $this->tune->get('tuneID'), 'should not have changed from 4');
} }
@@ -150,38 +150,37 @@ class TuneTest extends TestCase
* @param (mixed) value to append * @param (mixed) value to append
* @param (Boolean) expected value for return value of append method * @param (Boolean) expected value for return value of append method
* *
* @dataProvider provider_append * @dataProvider providerAppend
*/ */
public function test_append($property, $value, $expected) public function testAppend($property, $value, $expected)
{ {
$success = $this->_tune->append($property, $value); $success = $this->tune->append($property, $value);
$this->assertEquals($expected, $success); $this->assertEquals($expected, $success);
if($success) if ($success) {
{ $this->assertContains($value, $this->tune->get($property));
$this->assertContains($value, $this->_tune->get($property));
} }
} }
public function provider_append() public function providerAppend()
{ {
return array( return [
array('Y', 1, FALSE), ['Y', 1, false],
array('X', 1, FALSE), ['X', 1, false],
array('T','title', TRUE), ['T', 'title', true],
array('T', array('of','titles'), FALSE), ['T', ['of', 'titles'], false],
array('A', 'author', TRUE), ['A', 'author', true],
array('C', 'composer', TRUE), ['C', 'composer', true],
array('G', 'Group', TRUE), ['G', 'Group', true],
array('H', 'history', TRUE), ['H', 'history', true],
array('O', 'Origin', TRUE), ['O', 'Origin', true],
array('R', 'Rhythm', TRUE), ['R', 'Rhythm', true],
array('collection', 'setting', FALSE), ['collection', 'setting', false],
array('collection', new Setting(), TRUE), ['collection', new Setting(), true],
array('collection', array(new Setting()), FALSE), ['collection', [new Setting()], false],
array('tuneHash', 'tuneHash', FALSE), ['tuneHash', 'tuneHash', false],
array('tuneHash', new Setting(), FALSE), ['tuneHash', new Setting(), false],
array('tuneHash', array(new Setting()), FALSE), ['tuneHash', [new Setting()], false],
); ];
} }
@@ -193,23 +192,20 @@ class TuneTest extends TestCase
* @param (array) $params list of properties to set on the objects * @param (array) $params list of properties to set on the objects
* @param (boolean) $expected result of running equals * @param (boolean) $expected result of running equals
* *
* @dataProvider provider_equals * @dataProvider providerEquals
*/ */
public function test_equals($params) public function testEquals($params)
{ {
// $this->markTestIncomplete(); // $this->markTestIncomplete();
$ob1 = new Tune(); $ob1 = new Tune();
$ob2 = new Tune(); $ob2 = new Tune();
foreach($params as $key => $val) foreach ($params as $key => $val) {
{ if (is_array($ob1->get($key))) {
if(is_array($ob1->get($key)))
{
$ob1->append($key, $val); $ob1->append($key, $val);
$ob2->append($key, $val); $ob2->append($key, $val);
} } else {
else {
$ob1->set($key, $val); $ob1->set($key, $val);
$ob2->set($key, $val); $ob2->set($key, $val);
} }
@@ -226,48 +222,44 @@ class TuneTest extends TestCase
* @param (array) $params list of properties to set on the objects * @param (array) $params list of properties to set on the objects
* @param (boolean) $expected result of running equals * @param (boolean) $expected result of running equals
* *
* @dataProvider provider_equals * @dataProvider providerEquals
*/ */
public function test_equals_fails($params) public function testEqualsFails($params)
{ {
$ob1 = new Tune(); $ob1 = new Tune();
$ob2 = new Tune(); $ob2 = new Tune();
foreach($params as $key => $val) foreach ($params as $key => $val) {
{ if ($key === 'collection') {
if($key === 'collection')
{
$ob1->set($key, $val); $ob1->set($key, $val);
} } elseif (is_array($ob1->get($key))) {
else if(is_array($ob1->get($key)))
{
$ob1->append($key, $val); $ob1->append($key, $val);
} } else {
else {
$ob1->set($key, $val); $ob1->set($key, $val);
} }
} }
$this->assertFalse(Tune::equals($ob1, $ob2)); $this->assertFalse(Tune::equals($ob1, $ob2));
} }
public function provider_equals()
public function providerEquals()
{ {
$setting1 = new Setting(array('settingID'=>5, 'tuneID'=>444)); $setting1 = new Setting(['settingID' => 5, 'tuneID' => 444]);
$setting2 = new Setting(array('settingID'=>3, 'tuneID'=>2244)); $setting2 = new Setting(['settingID' => 3, 'tuneID' => 2244]);
return array( return [
array( array('X'=>'2') ), [['X' => '2']],
array( array('T'=>'a title') ), [['T' => 'a title']],
array( array('A'=>'an author') ), [['A' => 'an author']],
array( array('C'=>'a composer') ), [['C' => 'a composer']],
array( array('G'=>'a group') ), [['G' => 'a group']],
array( array('H'=>'some history') ), [['H' => 'some history']],
array( array('O'=>'Plymouth') ), [['O' => 'Plymouth']],
array( array('R'=>'Jig') ), [['R' => 'Jig']],
array( array('collection' => array($setting1, $setting2) )) [['collection' => [$setting1, $setting2]]],
); ];
} }
public function test_isChanged() public function testIsChanged()
{ {
$tune = new Tune(); $tune = new Tune();
@@ -280,31 +272,30 @@ class TuneTest extends TestCase
} }
/** /**
* @dataProvider provider_get * @dataProvider providerGet
*/ */
public function test_get($key, $expected) public function testGet($key, $expected)
{ {
$result = $this->_tune->set($key, $expected); $result = $this->tune->set($key, $expected);
$result = $this->_tune->get($key); $result = $this->tune->get($key);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
public function provider_get() public function providerGet()
{ {
return array( return [
array('', FALSE), ['', false],
array('me', FALSE), ['me', false],
array('tuneID', 2), ['tuneID', 2],
array('X', '2'), ['X', '2'],
array('T', array('1','2')), ['T', ['1', '2']],
array('A', array(new Person(),new Person())), ['A', [new Person(), new Person()]],
array('C', array(new Person(),new Person())), ['C', [new Person(), new Person()]],
array('G', array('1','2')), ['G', ['1', '2']],
array('H', array('1','2')), ['H', ['1', '2']],
array('O', array('1','2')), ['O', ['1', '2']],
array('R', array('1','2')), ['R', ['1', '2']],
array('collection', array(new Setting())), ['collection', [new Setting()]],
); ];
} }
} }