diff --git a/composer.lock b/composer.lock index 8d2d759..c5dc7b2 100644 --- a/composer.lock +++ b/composer.lock @@ -85,6 +85,10 @@ "rest", "web service" ], + "support": { + "issues": "https://github.com/guzzle/guzzle/issues", + "source": "https://github.com/guzzle/guzzle/tree/7.3.0" + }, "funding": [ { "url": "https://github.com/GrahamCampbell", @@ -107,16 +111,16 @@ }, { "name": "guzzlehttp/promises", - "version": "1.4.1", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d" + "reference": "136a635e2b4a49b9d79e9c8fee267ffb257fdba0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/8e7d04f1f6450fef59366c399cfad4b9383aa30d", - "reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d", + "url": "https://api.github.com/repos/guzzle/promises/zipball/136a635e2b4a49b9d79e9c8fee267ffb257fdba0", + "reference": "136a635e2b4a49b9d79e9c8fee267ffb257fdba0", "shasum": "" }, "require": { @@ -128,7 +132,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "1.5-dev" } }, "autoload": { @@ -144,30 +148,63 @@ "MIT" ], "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, { "name": "Michael Dowling", "email": "mtdowling@gmail.com", "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" } ], "description": "Guzzle promises library", "keywords": [ "promise" ], - "time": "2021-03-07T09:25:29+00:00" + "support": { + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/1.5.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], + "time": "2021-10-07T13:05:22+00:00" }, { "name": "guzzlehttp/psr7", - "version": "2.0.0", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "1dc8d9cba3897165e16d12bb13d813afb1eb3fe7" + "reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/1dc8d9cba3897165e16d12bb13d813afb1eb3fe7", - "reference": "1dc8d9cba3897165e16d12bb13d813afb1eb3fe7", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/089edd38f5b8abba6cb01567c2a8aaa47cec4c72", + "reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72", "shasum": "" }, "require": { @@ -191,7 +228,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "2.1-dev" } }, "autoload": { @@ -204,13 +241,34 @@ "MIT" ], "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, { "name": "Michael Dowling", "email": "mtdowling@gmail.com", "homepage": "https://github.com/mtdowling" }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, { "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", "homepage": "https://github.com/Tobion" }, { @@ -230,20 +288,38 @@ "uri", "url" ], - "time": "2021-06-30T20:03:07+00:00" + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.1.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "time": "2021-10-06T17:43:30+00:00" }, { "name": "kaltura/api-client-library", - "version": "v17.2.0", + "version": "v17.11.0", "source": { "type": "git", "url": "https://github.com/kaltura/KalturaGeneratedAPIClientsPHP53.git", - "reference": "cdb27eba2bf096306f0c458d54966cfb4c283fad" + "reference": "91b13536fde71d2f61c5ac28645e27959f8e16c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kaltura/KalturaGeneratedAPIClientsPHP53/zipball/cdb27eba2bf096306f0c458d54966cfb4c283fad", - "reference": "cdb27eba2bf096306f0c458d54966cfb4c283fad", + "url": "https://api.github.com/repos/kaltura/KalturaGeneratedAPIClientsPHP53/zipball/91b13536fde71d2f61c5ac28645e27959f8e16c0", + "reference": "91b13536fde71d2f61c5ac28645e27959f8e16c0", "shasum": "" }, "require": { @@ -274,7 +350,11 @@ "video", "video platform" ], - "time": "2021-05-26T13:19:13+00:00" + "support": { + "issues": "https://github.com/kaltura/KalturaGeneratedAPIClientsPHP53/issues", + "source": "https://github.com/kaltura/KalturaGeneratedAPIClientsPHP53/tree/v17.11.0" + }, + "time": "2021-10-07T09:16:12+00:00" }, { "name": "psr/http-client", @@ -323,6 +403,9 @@ "psr", "psr-18" ], + "support": { + "source": "https://github.com/php-fig/http-client/tree/master" + }, "time": "2020-06-29T06:28:15+00:00" }, { @@ -375,6 +458,9 @@ "request", "response" ], + "support": { + "source": "https://github.com/php-fig/http-factory/tree/master" + }, "time": "2019-04-30T12:38:16+00:00" }, { @@ -425,6 +511,9 @@ "request", "response" ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/master" + }, "time": "2016-08-06T14:39:51+00:00" }, { @@ -465,6 +554,10 @@ } ], "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, "time": "2019-03-08T08:55:37+00:00" } ], @@ -518,6 +611,10 @@ "constructor", "instantiate" ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/1.4.0" + }, "funding": [ { "url": "https://www.doctrine-project.org/sponsorship.html", @@ -580,6 +677,10 @@ "object", "object graph" ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.10.2" + }, "funding": [ { "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", @@ -590,16 +691,16 @@ }, { "name": "phar-io/manifest", - "version": "2.0.1", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "85265efd3af7ba3ca4b2a2c34dbfc5788dd29133" + "reference": "97803eca37d319dfa7826cc2437fc020857acb53" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/85265efd3af7ba3ca4b2a2c34dbfc5788dd29133", - "reference": "85265efd3af7ba3ca4b2a2c34dbfc5788dd29133", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53", "shasum": "" }, "require": { @@ -642,7 +743,11 @@ } ], "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", - "time": "2020-06-27T14:33:11+00:00" + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.3" + }, + "time": "2021-07-20T11:28:43+00:00" }, { "name": "phar-io/version", @@ -689,6 +794,10 @@ } ], "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.1.0" + }, "time": "2021-02-23T14:00:09+00:00" }, { @@ -738,6 +847,10 @@ "reflection", "static analysis" ], + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + }, "time": "2020-06-27T09:03:43+00:00" }, { @@ -790,20 +903,24 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" + }, "time": "2020-09-03T19:13:55+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.4.0", + "version": "1.5.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0" + "reference": "a12f7e301eb7258bb68acd89d4aefa05c2906cae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", - "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/a12f7e301eb7258bb68acd89d4aefa05c2906cae", + "reference": "a12f7e301eb7258bb68acd89d4aefa05c2906cae", "shasum": "" }, "require": { @@ -811,7 +928,8 @@ "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "ext-tokenizer": "*" + "ext-tokenizer": "*", + "psalm/phar": "^4.8" }, "type": "library", "extra": { @@ -835,37 +953,41 @@ } ], "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "time": "2020-09-17T18:55:26+00:00" + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.5.1" + }, + "time": "2021-10-02T14:08:47+00:00" }, { "name": "phpspec/prophecy", - "version": "1.13.0", + "version": "1.14.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea" + "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/be1996ed8adc35c3fd795488a653f4b518be70ea", - "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e", + "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e", "shasum": "" }, "require": { "doctrine/instantiator": "^1.2", - "php": "^7.2 || ~8.0, <8.1", + "php": "^7.2 || ~8.0, <8.2", "phpdocumentor/reflection-docblock": "^5.2", "sebastian/comparator": "^3.0 || ^4.0", "sebastian/recursion-context": "^3.0 || ^4.0" }, "require-dev": { - "phpspec/phpspec": "^6.0", + "phpspec/phpspec": "^6.0 || ^7.0", "phpunit/phpunit": "^8.0 || ^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11.x-dev" + "dev-master": "1.x-dev" } }, "autoload": { @@ -898,20 +1020,24 @@ "spy", "stub" ], - "time": "2021-03-17T13:42:18+00:00" + "support": { + "issues": "https://github.com/phpspec/prophecy/issues", + "source": "https://github.com/phpspec/prophecy/tree/1.14.0" + }, + "time": "2021-09-10T09:02:12+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "7.0.14", + "version": "7.0.15", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "bb7c9a210c72e4709cdde67f8b7362f672f2225c" + "reference": "819f92bba8b001d4363065928088de22f25a3a48" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/bb7c9a210c72e4709cdde67f8b7362f672f2225c", - "reference": "bb7c9a210c72e4709cdde67f8b7362f672f2225c", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/819f92bba8b001d4363065928088de22f25a3a48", + "reference": "819f92bba8b001d4363065928088de22f25a3a48", "shasum": "" }, "require": { @@ -920,7 +1046,7 @@ "php": ">=7.2", "phpunit/php-file-iterator": "^2.0.2", "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^3.1.1 || ^4.0", + "phpunit/php-token-stream": "^3.1.3 || ^4.0", "sebastian/code-unit-reverse-lookup": "^1.0.1", "sebastian/environment": "^4.2.2", "sebastian/version": "^2.0.1", @@ -961,26 +1087,30 @@ "testing", "xunit" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/7.0.15" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-12-02T13:39:03+00:00" + "time": "2021-07-26T12:20:09+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "2.0.3", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "4b49fb70f067272b659ef0174ff9ca40fdaa6357" + "reference": "28af674ff175d0768a5a978e6de83f697d4a7f05" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/4b49fb70f067272b659ef0174ff9ca40fdaa6357", - "reference": "4b49fb70f067272b659ef0174ff9ca40fdaa6357", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/28af674ff175d0768a5a978e6de83f697d4a7f05", + "reference": "28af674ff175d0768a5a978e6de83f697d4a7f05", "shasum": "" }, "require": { @@ -1017,13 +1147,17 @@ "filesystem", "iterator" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/2.0.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-11-30T08:25:21+00:00" + "time": "2021-07-19T06:46:01+00:00" }, { "name": "phpunit/php-text-template", @@ -1064,6 +1198,10 @@ "keywords": [ "template" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/1.2.1" + }, "time": "2015-06-21T13:50:34+00:00" }, { @@ -1113,6 +1251,10 @@ "keywords": [ "timer" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/2.1.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1123,29 +1265,29 @@ }, { "name": "phpunit/php-token-stream", - "version": "3.1.2", + "version": "4.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "472b687829041c24b25f475e14c2f38a09edf1c2" + "reference": "a853a0e183b9db7eed023d7933a858fa1c8d25a3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/472b687829041c24b25f475e14c2f38a09edf1c2", - "reference": "472b687829041c24b25f475e14c2f38a09edf1c2", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/a853a0e183b9db7eed023d7933a858fa1c8d25a3", + "reference": "a853a0e183b9db7eed023d7933a858fa1c8d25a3", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=7.1" + "php": "^7.3 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1168,6 +1310,10 @@ "keywords": [ "tokenizer" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-token-stream/issues", + "source": "https://github.com/sebastianbergmann/php-token-stream/tree/master" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1175,20 +1321,20 @@ } ], "abandoned": true, - "time": "2020-11-30T08:38:46+00:00" + "time": "2020-08-04T08:28:15+00:00" }, { "name": "phpunit/phpunit", - "version": "8.5.17", + "version": "8.5.21", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "79067856d85421c56d413bd238d4e2cd6b0e54da" + "reference": "50a58a60b85947b0bee4c8ecfe0f4bbdcf20e984" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/79067856d85421c56d413bd238d4e2cd6b0e54da", - "reference": "79067856d85421c56d413bd238d4e2cd6b0e54da", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/50a58a60b85947b0bee4c8ecfe0f4bbdcf20e984", + "reference": "50a58a60b85947b0bee4c8ecfe0f4bbdcf20e984", "shasum": "" }, "require": { @@ -1200,12 +1346,12 @@ "ext-xml": "*", "ext-xmlwriter": "*", "myclabs/deep-copy": "^1.10.0", - "phar-io/manifest": "^2.0.1", + "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=7.2", "phpspec/prophecy": "^1.10.3", "phpunit/php-code-coverage": "^7.0.12", - "phpunit/php-file-iterator": "^2.0.2", + "phpunit/php-file-iterator": "^2.0.4", "phpunit/php-text-template": "^1.2.1", "phpunit/php-timer": "^2.1.2", "sebastian/comparator": "^3.0.2", @@ -1258,6 +1404,10 @@ "testing", "xunit" ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "source": "https://github.com/sebastianbergmann/phpunit/tree/8.5.21" + }, "funding": [ { "url": "https://phpunit.de/donate.html", @@ -1268,7 +1418,7 @@ "type": "github" } ], - "time": "2021-06-23T05:12:43+00:00" + "time": "2021-09-25T07:37:20+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -1313,6 +1463,10 @@ ], "description": "Looks up which function or method a line of code belongs to", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/1.0.2" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1383,6 +1537,10 @@ "compare", "equality" ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/3.0.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1445,6 +1603,10 @@ "unidiff", "unified diff" ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/3.0.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1504,6 +1666,10 @@ "environment", "hhvm" ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/4.2.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1577,6 +1743,10 @@ "export", "exporter" ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/3.1.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1637,6 +1807,10 @@ "keywords": [ "global state" ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/3.0.1" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1690,6 +1864,10 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/3.0.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1741,6 +1919,10 @@ ], "description": "Allows reflection of object attributes, including inherited and non-public ones", "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/1.1.2" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1800,6 +1982,10 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/3.0.1" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1848,12 +2034,17 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "support": { + "issues": "https://github.com/sebastianbergmann/resource-operations/issues", + "source": "https://github.com/sebastianbergmann/resource-operations/tree/2.0.2" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], + "abandoned": true, "time": "2020-11-30T07:30:19+00:00" }, { @@ -1900,6 +2091,10 @@ ], "description": "Collection of value objects that represent the types of the PHP type system", "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/1.1.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1949,6 +2144,10 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/master" + }, "time": "2016-10-03T07:35:21+00:00" }, { @@ -2011,6 +2210,9 @@ "polyfill", "portable" ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -2029,16 +2231,16 @@ }, { "name": "theseer/tokenizer", - "version": "1.2.0", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "75a63c33a8577608444246075ea0af0d052e452a" + "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/75a63c33a8577608444246075ea0af0d052e452a", - "reference": "75a63c33a8577608444246075ea0af0d052e452a", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", + "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", "shasum": "" }, "require": { @@ -2065,13 +2267,17 @@ } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + }, "funding": [ { "url": "https://github.com/theseer", "type": "github" } ], - "time": "2020-07-12T23:59:07+00:00" + "time": "2021-07-28T10:34:58+00:00" }, { "name": "webmozart/assert", @@ -2125,6 +2331,10 @@ "check", "validate" ], + "support": { + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/1.10.0" + }, "time": "2021-03-09T10:59:23+00:00" } ], @@ -2137,5 +2347,5 @@ "php": ">=7.2.0" }, "platform-dev": [], - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.1.0" } diff --git a/src/PhpAlly.php b/src/PhpAlly.php index 6f16f2e..76fed4d 100644 --- a/src/PhpAlly.php +++ b/src/PhpAlly.php @@ -22,7 +22,11 @@ public function checkMany($content, $ruleIds = [], $options = []) foreach ($ruleIds as $ruleId) { try { - $className = $ruleId; + $className = str_replace( + ['VideosEmbeddedOrLinkedNeedCaptions','VideosHaveAutoGeneratedCaptions','VideoCaptionsMatchCourseLanguage'], + 'VideoScan', + $ruleId + ); if (!class_exists($className)) { $report->setError('Rule does not exist.'); continue; diff --git a/src/Rule/BaseRule.php b/src/Rule/BaseRule.php index 356157d..cadab99 100644 --- a/src/Rule/BaseRule.php +++ b/src/Rule/BaseRule.php @@ -242,14 +242,15 @@ public function elementContainsReadableText($element) return false; } - public function setIssue($element, $previewElement = null, $metadata = null) + public function setIssue($element, $ruleId = null, $metadata = null) { - $ruleId = str_replace(['CidiLabs\\PhpAlly\\Rule\\','App\\Rule\\'], '', $this->id()); - - if (!$previewElement) { - $previewElement = $this->previewElement; + if (!isset($ruleId)) { + $ruleId = $this->id(); } + $ruleId = str_replace(['CidiLabs\\PhpAlly\\Rule\\','App\\Rule\\'], '', $ruleId); + $previewElement = $this->previewElement; + if ($element) { $elementClasses = $element->getAttribute('class'); if ($elementClasses && (strpos($elementClasses, 'phpally-ignore') !== false)) { diff --git a/src/Rule/VideoCaptionsMatchCourseLanguage.php b/src/Rule/VideoCaptionsMatchCourseLanguage.php deleted file mode 100644 index c5255a6..0000000 --- a/src/Rule/VideoCaptionsMatchCourseLanguage.php +++ /dev/null @@ -1,60 +0,0 @@ -getAllElements(array('a', 'embed', 'iframe', 'script')) as $video) { - $attr = ($video->tagName == 'a') ? 'href' : 'src'; - if ($video->hasAttribute($attr)) { - $attr_val = $video->getAttribute($attr); - $captionState = $this->getCaptionState($attr_val); - if ($captionState != self::VIDEO_HAS_CAPTIONS) { - $this->setIssue($video); - } - } - } - - return count($this->issues); - } - - public function getCaptionState($attr_val) - { - $search_youtube = '/(youtube|youtu.be)/'; - $search_vimeo = '/(vimeo)/'; - $search_kaltura = '/(kaltura)/'; - - if (preg_match($search_youtube, $attr_val)) { - $service = new Youtube(new \GuzzleHttp\Client(['http_errors' => false]), $this->lang, $this->options['youtubeApiKey']); - } elseif (preg_match($search_vimeo, $attr_val)) { - $service = new Vimeo(new \GuzzleHttp\Client(['http_errors' => false]), $this->lang, $this->options['vimeoApiKey']); - } else if (preg_match($search_kaltura, $attr_val)) { - $service = new Kaltura($this->lang, $this->options['kalturaApiKey'], $this->options['kalturaUsername']); - } - if (isset($service)) { - $captionState = $service->captionsLanguage($attr_val); - return $captionState; - } - - return self::VIDEO_HAS_CAPTIONS; - } -} \ No newline at end of file diff --git a/src/Rule/VideoScan.php b/src/Rule/VideoScan.php new file mode 100644 index 0000000..cdba227 --- /dev/null +++ b/src/Rule/VideoScan.php @@ -0,0 +1,130 @@ +getAllElements(array('a', 'embed', 'iframe', 'script')) as $video) { + $attr = ($video->tagName == 'a') ? 'href' : 'src'; + if ($video->hasAttribute($attr)) { + // Get URL + $attr_val = $video->getAttribute($attr); + // Get provider (Youtube, Vimeo, or Kaltura class) + $provider = $this->getVideoProvider($attr_val); + // Get caption data + $captionData = $this->getCaptionData($attr_val, $provider); + + if(isset($captionData) && isset($provider)) { + $this->checkCaptionsExist($captionData, $provider, $video); + $this->checkCaptionsLanguage($captionData, $provider, $video); + $this->checkCaptionsAutoGenerated($captionData, $provider, $video); + } + } + } + + return count($this->issues); + } + + // Scan rule functions + + // VideosEmbeddedOrLinkedNeedCaptions + public function checkCaptionsExist($captionData, $provider, $video) + { + // Use provider to call + if (method_exists($provider, 'captionsMissing')) { + $captionState = $provider->captionsMissing($captionData); + + if ($captionState != self::SUCCESS) { + $this->setIssue($video, 'VideosEmbeddedOrLinkedNeedCaptions'); + } + } + } + + // VideoCaptionsMatchCourseLanguage + public function checkCaptionsLanguage($captionData, $provider, $video) + { + // Use provider to call + if (method_exists($provider, 'captionsLanguage')) { + $captionState = $provider->captionsLanguage($captionData); + + if ($captionState != self::SUCCESS) { + $this->setIssue($video, 'VideoCaptionsMatchCourseLanguage'); + } + } + } + + // CaptionsAutoGenerated + public function checkCaptionsAutoGenerated($captionData, $provider, $video) + { + // Use provider to call + if (method_exists($provider, 'captionsAutoGenerated')) { + $captionState = $provider->captionsAutoGenerated($captionData); + + if ($captionState != self::SUCCESS) { + $this->setIssue($video, 'VideosHaveAutoGeneratedCaptions'); + } + } + } + + // Helpers + + public function getVideoProvider($url) + { + $search_youtube = '/(youtube|youtu.be)/'; + $search_vimeo = '/(vimeo)/'; + $search_kaltura = '/(kaltura)/'; + + if (preg_match($search_youtube, $url)) { + if (!isset($this->youtube)) { + $this->youtube = new Youtube(new \GuzzleHttp\Client(['http_errors' => false]), $this->lang, $this->options['youtubeApiKey']); + } + return $this->youtube; + } elseif (preg_match($search_vimeo, $url)) { + if (!isset($this->vimeo)) { + $this->vimeo = new Vimeo(new \GuzzleHttp\Client(['http_errors' => false]), $this->lang, $this->options['vimeoApiKey']); + } + return $this->vimeo; + } else if (preg_match($search_kaltura, $url)) { + if (!isset($this->kaltura)) { + $this->kaltura = new Kaltura($this->lang, $this->options['kalturaApiKey'], $this->options['kalturaUsername']); + } + return $this->kaltura; + } + + return null; + } + + public function getCaptionData($url, $provider) + { + if (isset($provider)) { + return $provider->getVideoData($url); + } + + return null; + } +} \ No newline at end of file diff --git a/src/Rule/VideosEmbeddedOrLinkedNeedCaptions.php b/src/Rule/VideosEmbeddedOrLinkedNeedCaptions.php deleted file mode 100644 index 1d5585e..0000000 --- a/src/Rule/VideosEmbeddedOrLinkedNeedCaptions.php +++ /dev/null @@ -1,68 +0,0 @@ -getAllElements(array('a', 'embed', 'iframe', 'script')) as $video) { - $attr = ($video->tagName == 'a') ? 'href' : 'src'; - if ($video->hasAttribute($attr)) { - $attr_val = $video->getAttribute($attr); - $captionState = $this->getCaptionState($attr_val); - if ($captionState != self::VIDEO_HAS_CAPTIONS) { - $this->setIssue($video); - } - - } - } - - return count($this->issues); - } - - public function getCaptionState($attr_val) - { - $search_youtube = '/(youtube|youtu.be)/'; - $search_vimeo = '/(vimeo)/'; - $search_kaltura = '/(kaltura)/'; - - if (preg_match($search_youtube, $attr_val)) { - if (!empty($this->options['youtubeApiKey'])) { - $service = new Youtube(new \GuzzleHttp\Client(['http_errors' => false]), $this->lang, $this->options['youtubeApiKey']); - } - } elseif (preg_match($search_vimeo, $attr_val)) { - if (!empty($this->options['vimeoApiKey'])) { - $service = new Vimeo(new \GuzzleHttp\Client(['http_errors' => false]), $this->lang, $this->options['vimeoApiKey']); - } - } else if (preg_match($search_kaltura, $attr_val)) { - if (!empty($this->options['kalturaApiKey'])) { - $service = new Kaltura($this->lang, $this->options['kalturaApiKey'], $this->options['kalturaUsername']); - } - } - if (isset($service)) { - $captionState = $service->captionsMissing($attr_val); - return $captionState; - } - - return self::VIDEO_HAS_CAPTIONS; - } -} diff --git a/src/Rule/VideosHaveAutoGeneratedCaptions.php b/src/Rule/VideosHaveAutoGeneratedCaptions.php deleted file mode 100644 index 99ae127..0000000 --- a/src/Rule/VideosHaveAutoGeneratedCaptions.php +++ /dev/null @@ -1,51 +0,0 @@ -getAllElements(array('a', 'embed', 'iframe')) as $video) { - $attr = ($video->tagName == 'a') ? 'href' : 'src'; - if ($video->hasAttribute($attr)) { - $attr_val = $video->getAttribute($attr); - $captionState = $this->getCaptionState($attr_val); - if ($captionState != self::VIDEO_HAS_CUSTOM_CAPTIONS) { - $this->setIssue($video); - } - } - } - - return count($this->issues); - } - - public function getCaptionState($attr_val) - { - $service = null; - $search_youtube = '/(youtube|youtu.be)/'; - - if (preg_match($search_youtube, $attr_val)) { - $service = new Youtube(new \GuzzleHttp\Client(['http_errors' => false]), $this->lang, $this->options['youtubeApiKey']); - } - - if (isset($service)) { - $captionState = $service->captionsAutoGenerated($attr_val); - return $captionState; - } - - return self::VIDEO_HAS_CUSTOM_CAPTIONS; - } -} diff --git a/src/Kaltura.php b/src/Video/Kaltura.php similarity index 53% rename from src/Kaltura.php rename to src/Video/Kaltura.php index d9cd1c7..f24b935 100644 --- a/src/Kaltura.php +++ b/src/Video/Kaltura.php @@ -1,6 +1,6 @@ api_key); - $username_trimmed = trim($this->username); - if (empty($key_trimmed) || empty($username_trimmed)) { - return self::KALTURA_SUCCESS; - } - - if(($video_id = $this->isKalturaVideo($link_url)) && ($partner_id = $this->getPartnerID($link_url))) { - $result = $this->getVideoData($video_id, $partner_id); - - if($result->totalCount === 0) { - return self::KALTURA_FAIL; - } + if($captionData->totalCount === 0) { + return self::KALTURA_FAIL; } + return self::KALTURA_SUCCESS; } /** * Checks to see if a video is missing caption information in YouTube - * @param string $link_url The URL to the video or video resource + * @param object $captionData The caption data for the video * @return int 0 if captions are manual and wrong language, 1 if video is private, 2 if there are no captions or if manually generated and correct language */ - function captionsLanguage($link_url) + function captionsLanguage($captionData) { - // If the API key or username is blank, flag the video for manual inspection - $key_trimmed = trim($this->api_key); - $username_trimmed = trim($this->username); - if (empty($key_trimmed) || empty($username_trimmed)) { - return self::KALTURA_SUCCESS; + // If for whatever reason course_locale is blank, set it to English + $course_locale = $this->language; + if ($course_locale === '' || is_null($course_locale)) { + $course_locale = 'en'; } - if(($video_id = $this->isKalturaVideo($link_url)) && ($partner_id = $this->getPartnerID($link_url))) { - $result = $this->getVideoData($video_id, $partner_id); - $captionsArray = $result->objects; - foreach($captionsArray as $caption) - { - if(substr($caption->languageCode, 0, 2) === substr($this->language, 0, 2)) { - return self::KALTURA_SUCCESS; - } - } - return self::KALTURA_FAIL; + $captionsArray = $captionData->objects; + foreach($captionsArray as $caption) + { + if(substr($caption->languageCode, 0, 2) === substr($course_locale, 0, 2)) { + return self::KALTURA_SUCCESS; + } } - - return self::KALTURA_SUCCESS; + return empty($captionsArray) ? self::KALTURA_SUCCESS : self::KALTURA_FAIL; } /** @@ -86,7 +70,7 @@ function captionsLanguage($link_url) * @param string $link_url The URL to the video or video resource * @return mixed FALSE if it's not a Kaltura video, or a string video ID if it is */ - private function isKalturaVideo($link_url) + function isKalturaVideo($link_url) { $regex = '@\bkaltura\b.*\bentry_id=(.{10})@'; $matches = null; @@ -97,7 +81,7 @@ private function isKalturaVideo($link_url) return false; } - private function getPartnerID($link_url) + function getPartnerID($link_url) { $regex = '@partner_id/(.{7})@'; $matches = null; @@ -111,29 +95,44 @@ private function getPartnerID($link_url) /** * Makes the api call to get the caption data for the video. * @param string $link_url The URL to the video or video resource - * @return mixed FALSE if the api calls fails or its not a Kaltura video, + * @return mixed null if the api calls fails or its not a Kaltura video, * or an array of caption objects if it is */ - function getVideoData($video_id, $partner_id) + function getVideoData($link_url) { - $config = new KalturaConfiguration($partner_id); - $config->setServiceUrl('https://www.kaltura.com'); - $this->client = new KalturaClient($config); - $ks = $this->client->generateSession( - $this->api_key, - $this->username, - SessionType::ADMIN, - $partner_id); - $this->client->setKS($ks); - - $captionPlugin = CaptionPlugin::get($this->client); - $filter = new AssetFilter(); - $filter->entryIdIn = $video_id; - $pager = new FilterPager(); - - $result = $captionPlugin->captionAsset->listAction($filter, $pager); - - return $result; + // If the API key or username is blank, flag the video for manual inspection + $key_trimmed = trim($this->api_key); + $username_trimmed = trim($this->username); + if (empty($key_trimmed) || empty($username_trimmed)) { + return false; + } + + $video_id = $this->isKalturaVideo($link_url); + $partner_id = $this->getPartnerID($link_url); + + if ($video_id && $partner_id) { + + $config = new KalturaConfiguration($partner_id); + $config->setServiceUrl('https://www.kaltura.com'); + $this->client = new KalturaClient($config); + $ks = $this->client->generateSession( + $this->api_key, + $this->username, + SessionType::ADMIN, + $partner_id); + $this->client->setKS($ks); + + $captionPlugin = CaptionPlugin::get($this->client); + $filter = new AssetFilter(); + $filter->entryIdIn = $video_id; + $pager = new FilterPager(); + + $result = $captionPlugin->captionAsset->listAction($filter, $pager); + + return $result; + } + + return null; } } \ No newline at end of file diff --git a/src/Vimeo.php b/src/Video/Vimeo.php similarity index 50% rename from src/Vimeo.php rename to src/Video/Vimeo.php index 44d2cea..adc6745 100644 --- a/src/Vimeo.php +++ b/src/Video/Vimeo.php @@ -1,6 +1,6 @@ search_url; + $body = json_decode($captionData->getBody()); - // If the API key is blank, flag the video for manual inspection - $key_trimmed = trim($this->api_key); - if (empty($key_trimmed)) { + // Response header code is used to determine if video exists, doesn't exist, or is unaccessible + // 400 means a video is private, 404 means a video doesn't exist, and 200 means the video exists + if ($captionData->getStatusCode() >= 400) { return self::VIMEO_FAILED_CONNECTION; + } else if (($captionData->getStatusCode() === 200) && $body->total === 0) { + return self::VIMEO_FAIL; } - - if ($vimeo_id = $this->isVimeoVideo($link_url)) { - $response = $this->getVideoData($vimeo_id); - - $body = json_decode($response->getBody()); - - // Response header code is used to determine if video exists, doesn't exist, or is unaccessible - // 400 means a video is private, 404 means a video doesn't exist, and 200 means the video exists - if ($response->getStatusCode() >= 400) { - return self::VIMEO_FAILED_CONNECTION; - } else if (($response->getStatusCode() === 200) && $body->total === 0) { - return self::VIMEO_FAIL; - } - } + return self::VIMEO_SUCCESS; } @@ -59,45 +48,31 @@ function captionsMissing($link_url) * @param string $link_url The URL to the video or video resource * @return int 0 if captions are manual and wrong language, 1 if video is private, 2 if there are no captions or if manually generated and correct language */ - function captionsLanguage($link_url) + function captionsLanguage($captionData) { - $url = $this->search_url; - // If the API key is blank, flag the video for manual inspection - $key_trimmed = trim($this->api_key); - if (empty($key_trimmed)) { - return self::VIMEO_FAILED_CONNECTION; - } - // If for whatever reason course_locale is blank, set it to English $course_locale = $this->language; if ($course_locale === '' || is_null($course_locale)) { $course_locale = 'en'; } - if ($vimeo_id = $this->isVimeoVideo($link_url)) { - $url = $url . $vimeo_id . '/texttracks'; - $response = $this->getVideoData($vimeo_id); + $body = json_decode($captionData->getBody()); - $body = json_decode($response->getBody()); + // Response header code is used to determine if video exists, doesn't exist, or is unaccessible + // 400 means a video is private, 404 means a video doesn't exist, and 200 means the video exists + if ($captionData->getStatusCode() === 400 || $captionData->getStatusCode() === 404) { + return self::VIMEO_FAILED_CONNECTION; + } else if (($captionData->getStatusCode() === 200) && $body->total === 0) { + return self::VIMEO_SUCCESS; + } - // Response header code is used to determine if video exists, doesn't exist, or is unaccessible - // 400 means a video is private, 404 means a video doesn't exist, and 200 means the video exists - if ($response->getStatusCode() === 400 || $response->getStatusCode() === 404) { - return self::VIMEO_FAILED_CONNECTION; - } else if (($response->getStatusCode() === 200) && $body->total === 0) { + foreach ($body->data as $track) { + if (substr($track->language, 0, 2) === $course_locale) { return self::VIMEO_SUCCESS; } - - foreach ($body->data as $track) { - if (substr($track->language, 0, 2) === $course_locale) { - return self::VIMEO_SUCCESS; - } - } - - return self::VIMEO_FAIL; } - return self::VIMEO_SUCCESS; + return self::VIMEO_FAIL; } /** @@ -115,12 +90,24 @@ private function isVimeoVideo($link_url) return false; } - function getVideoData($vimeo_id) + /** + * Gets the caption data from the youtube api + * @param string $link_url The URL to the video or video resource + * @return mixed $response Returns response object if api call can be made, null otherwise + */ + function getVideoData($link_url) { - $url = $this->search_url . $vimeo_id . '/texttracks'; + $key_trimmed = trim($this->api_key); + $vimeo_id = $this->isVimeoVideo($link_url); + + if ($vimeo_id && !empty($key_trimmed)) { + $url = $this->search_url . $vimeo_id . '/texttracks'; + + return $this->client->request('GET', $url, ['headers' => [ + 'Authorization' => "Bearer $this->api_key" + ]]); + } - return $this->client->request('GET', $url, ['headers' => [ - 'Authorization' => "Bearer $this->api_key" - ]]); + return null; } } diff --git a/src/Video/Youtube.php b/src/Video/Youtube.php new file mode 100644 index 0000000..0e35ab1 --- /dev/null +++ b/src/Video/Youtube.php @@ -0,0 +1,154 @@ +client = $client; + $this->language = $language; + $this->api_key = $api_key; + } + + /** + * Checks to see if a video is missing caption information in YouTube + * @param object $captionData The caption data for the video + * @return int 0 if captions are missing, 1 if video is private, 2 if captions exist or not a video + */ + public function captionsMissing($captionData) + { + if ($captionData->getStatusCode() >= 400) { + return self::YOUTUBE_NO_VIDEO; + } + + $items = json_decode($captionData->getBody())->items; + + return !(empty($items)) ? self::YOUTUBE_SUCCESS : self::YOUTUBE_FAIL; + } + + /** + * Checks to see if a video is missing caption information in YouTube + * @param object $captionData The caption data for the video + * @return int 0 if captions are missing, 1 if video is private, 2 if captions exist or not a video + */ + public function captionsAutoGenerated($captionData) + { + if ($captionData->getStatusCode() >= 400) { + return self::YOUTUBE_NO_VIDEO; + } + + $items = json_decode($captionData->getBody())->items; + + // Looks through the captions and checks if any were not auto-generated + foreach ($items as $track) { + if (strtolower($track->snippet->trackKind) != 'asr') { + return self::YOUTUBE_SUCCESS; + } + } + + return empty($items) ? self::YOUTUBE_SUCCESS : self::YOUTUBE_FAIL; + } + + /** + * Checks to see if a video is missing caption information in YouTube + * @param object $captionData The caption data for the video + * @return int 0 if captions are missing, 1 if video is private, 2 if captions exist or not a video + */ + public function captionsLanguage($captionData) + { + $foundManual = false; + // If for whatever reason course_locale is blank, set it to English + $course_locale = $this->language; + if ($course_locale === '' || is_null($course_locale)) { + $course_locale = 'en'; + } + + // If the video was pulled due to copyright violations, is unlisted, or is unavailable, the reponse header will be 404 + if ($captionData->getStatusCode() >= 400) { + return self::YOUTUBE_NO_VIDEO; + } + + $items = json_decode($captionData->getBody())->items; + + // Looks through the captions and checks if they are of the correct language + foreach ($items as $track) { + $trackKind = strtolower($track->snippet->trackKind); + + //If the track was manually generated, set the flag to true + if ($trackKind != 'asr') { + $foundManual = true; + } + + if (substr($track->snippet->language, 0, 2) == $course_locale && $trackKind != 'asr') { + return self::YOUTUBE_SUCCESS; + } + } + + //If we found any manual captions and have not returned, then none are the correct language + if ($foundManual === true) { + return self::YOUTUBE_FAIL; + } + + return self::YOUTUBE_SUCCESS; + } + + /** + * Checks to see if the provided link URL is a YouTube video. If so, it returns + * the video code, if not, it returns null. + * @param string $link_url The URL to the video or video resource + * @return mixed FALSE if it's not a YouTube video, or a string video ID if it is + */ + function isYouTubeVideo($link_url) + { + $matches = null; + foreach ($this->regex as $pattern) { + if (preg_match($pattern, trim($link_url), $matches)) { + return $matches[1]; + } + } + return false; + } + + /** + * Gets the caption data from the youtube api + * @param string $link_url The URL to the video or video resource + * @return mixed $response Returns response object if api call can be made, null otherwise + */ + function getVideoData($link_url) + { + $key_trimmed = trim($this->api_key); + $youtube_id = $this->isYouTubeVideo($link_url); + + if ($youtube_id && !empty($key_trimmed)) { + $url = $this->search_url . $youtube_id . '&key=' . $this->api_key; + $response = $this->client->request('GET', $url); + + return $response; + } + + return null; + } +} diff --git a/src/Youtube.php b/src/Youtube.php deleted file mode 100644 index 1bae18f..0000000 --- a/src/Youtube.php +++ /dev/null @@ -1,180 +0,0 @@ -client = $client; - $this->language = $language; - $this->api_key = $api_key; - } - - /** - * Checks to see if a video is missing caption information in YouTube - * @param string $link_url The URL to the video or video resource - * @return int 0 if captions are missing, 1 if video is private, 2 if captions exist or not a video - */ - public function captionsMissing($link_url) - { - $url = $this->search_url; - - // If the API key is blank, flag the video for manual inspection - $key_trimmed = trim($this->api_key); - if (empty($key_trimmed)) { - return self::YOUTUBE_NO_VIDEO; - } - - if ($youtube_id = $this->isYouTubeVideo($link_url)) { - $response = $this->getVideoData($youtube_id); - - if ($response->getStatusCode() >= 400) { - return self::YOUTUBE_NO_VIDEO; - } - - $items = json_decode($response->getBody())->items; - - return !(empty($items)) ? self::YOUTUBE_SUCCESS : self::YOUTUBE_FAIL; - } - - return self::YOUTUBE_SUCCESS; - } - - public function captionsAutoGenerated($link_url) - { - $url = $this->search_url; - - // If the API key is blank, flag the video for manual inspection - $key_trimmed = trim($this->api_key); - if (empty($key_trimmed)) { - return self::YOUTUBE_NO_VIDEO; - } - - if ($youtube_id = $this->isYouTubeVideo($link_url)) { - $response = $this->getVideoData($youtube_id); - - if ($response->getStatusCode() >= 400) { - return self::YOUTUBE_NO_VIDEO; - } - - $items = json_decode($response->getBody())->items; - - // Looks through the captions and checks if any were not auto-generated - foreach ($items as $track) { - if (strtolower($track->snippet->trackKind) != 'asr') { - return self::YOUTUBE_SUCCESS; - } - } - - return self::YOUTUBE_FAIL; - } - - // If we can't get to the video we will assume it passes, since we can't prove otherwise. :) - return self::YOUTUBE_SUCCESS; - } - - /** - * Checks to see if a video is missing caption information in YouTube - * @param string $link_url The URL to the video or video resource - * @return int 0 if captions are manual and wrong language, 1 if video is private, 2 if captions are auto-generated or manually generated and correct language - */ - public function captionsLanguage($link_url) - { - $url = $this->search_url; - $api_key = $this->api_key; - $foundManual = false; - - // If the API key is blank, flag the video for manual inspection - $key_trimmed = trim($api_key); - if (empty($key_trimmed)) { - return self::YOUTUBE_NO_VIDEO; - } - - // If for whatever reason course_locale is blank, set it to English - $course_locale = $this->language; - if ($course_locale === '' || is_null($course_locale)) { - $course_locale = 'en'; - } - - if ($youtube_id = $this->isYouTubeVideo($link_url)) { - $response = $this->getVideoData($youtube_id); - - // If the video was pulled due to copyright violations, is unlisted, or is unavailable, the reponse header will be 404 - if ($response->getStatusCode() >= 400) { - return self::YOUTUBE_NO_VIDEO; - } - - $items = json_decode($response->getBody())->items; - - // Looks through the captions and checks if they are of the correct language - foreach ($items as $track) { - $trackKind = strtolower($track->snippet->trackKind); - - //If the track was manually generated, set the flag to true - if ($trackKind != 'asr') { - $foundManual = true; - } - - if (substr($track->snippet->language, 0, 2) == $course_locale && $trackKind != 'asr') { - return self::YOUTUBE_SUCCESS; - } - } - - //If we found any manual captions and have not returned, then none are the correct language - if ($foundManual === true) { - return self::YOUTUBE_FAIL; - } - } - - return self::YOUTUBE_SUCCESS; - } - - /** - * Checks to see if the provided link URL is a YouTube video. If so, it returns - * the video code, if not, it returns null. - * @param string $link_url The URL to the video or video resource - * @return mixed FALSE if it's not a YouTube video, or a string video ID if it is - */ - private function isYouTubeVideo($link_url) - { - $matches = null; - foreach ($this->regex as $pattern) { - if (preg_match($pattern, trim($link_url), $matches)) { - return $matches[1]; - } - } - return false; - } - - function getVideoData($youtube_id) - { - $url = $this->search_url . $youtube_id . '&key=' . $this->api_key; - $response = $this->client->request('GET', $url); - - return $response; - } -} diff --git a/src/rules.json b/src/rules.json index 9802b43..5f9fcf4 100644 --- a/src/rules.json +++ b/src/rules.json @@ -31,9 +31,7 @@ "CidiLabs\\PhpAlly\\Rule\\PreShouldNotBeUsedForTabularValues", "CidiLabs\\PhpAlly\\Rule\\TableDataShouldHaveTableHeader", "CidiLabs\\PhpAlly\\Rule\\TableHeaderShouldHaveScope", - "CidiLabs\\PhpAlly\\Rule\\VideoCaptionsMatchCourseLanguage", "CidiLabs\\PhpAlly\\Rule\\VideoEmbedCheck", "CidiLabs\\PhpAlly\\Rule\\VideoProvidesCaptions", - "CidiLabs\\PhpAlly\\Rule\\VideosEmbeddedOrLinkedNeedCaptions", - "CidiLabs\\PhpAlly\\Rule\\VideosHaveAutoGeneratedCaptions" + "CidiLabs\\PhpAlly\\Rule\\VideoScan" ] diff --git a/tests/KalturaTest.php b/tests/KalturaTest.php index c36bc3b..e63199f 100644 --- a/tests/KalturaTest.php +++ b/tests/KalturaTest.php @@ -1,28 +1,13 @@ getMockBuilder(Kaltura::class) - ->setConstructorArgs(['en', 'testApiKey', 'testEmail']) - ->onlyMethods(array('getVideoData')) - ->getMock(); - - $this->assertEquals($kalturaMock->captionsMissing($link_url), 2); - } - public function testCaptionsMissingSuccess() { - $link_url = $this->test_url; - $json = '{ + $kaltura = new Kaltura('en', 'testApiKey', 'testEmail'); + $response = json_decode('{ "objects": [ { "languageCode": "en" @@ -30,58 +15,27 @@ public function testCaptionsMissingSuccess() ], "totalCount": 1, "objectType": "KalturaCaptionAssetListResponse" - }'; - - $kalturaMock = $this->getMockBuilder(Kaltura::class) - ->setConstructorArgs(['en', 'testApiKey', 'testEmail']) - ->onlyMethods(array('getVideoData')) - ->getMock(); + }'); - $kalturaMock->expects($this->once()) - ->method('getVideoData') - ->will($this->returnValue(json_decode($json))); - - $this->assertEquals($kalturaMock->captionsMissing($link_url), 2); + $this->assertEquals($kaltura->captionsMissing($response), 2); } public function testCaptionsMissingFailure() { - $link_url = $this->test_url; - $json = '{ + $kaltura = new Kaltura('en', 'testApiKey', 'testEmail'); + $response = json_decode('{ "objects": [], "totalCount": 0, "objectType": "KalturaCaptionAssetListResponse" - }'; - - $kalturaMock = $this->getMockBuilder(Kaltura::class) - ->setConstructorArgs(['en', 'testApiKey', 'testEmail']) - ->onlyMethods(array('getVideoData')) - ->getMock(); + }'); - $kalturaMock->expects($this->once()) - ->method('getVideoData') - ->will($this->returnValue(json_decode($json))); - - $this->assertEquals($kalturaMock->captionsMissing($link_url), 0); - } - - public function testCaptionsLanguageInvalidURL() - { - $link_url = 'fakeUrl'; - $result = false; - - $kalturaMock = $this->getMockBuilder(Kaltura::class) - ->setConstructorArgs(['en', 'testApiKey', 'testEmail']) - ->onlyMethods(array('getVideoData')) - ->getMock(); - - $this->assertEquals($kalturaMock->captionsLanguage($link_url), 2); + $this->assertEquals($kaltura->captionsMissing($response), 0); } public function testCaptionsLanguageSuccess() { - $link_url = $this->test_url; - $json = '{ + $kaltura = new Kaltura('en', 'testApiKey', 'testEmail'); + $response = json_decode('{ "objects": [ { "languageCode": "en" @@ -89,45 +43,27 @@ public function testCaptionsLanguageSuccess() ], "totalCount": 1, "objectType": "KalturaCaptionAssetListResponse" - }'; - - $kalturaMock = $this->getMockBuilder(Kaltura::class) - ->setConstructorArgs(['en', 'testApiKey', 'testEmail']) - ->onlyMethods(array('getVideoData')) - ->getMock(); + }'); - $kalturaMock->expects($this->once()) - ->method('getVideoData') - ->will($this->returnValue(json_decode($json))); - - $this->assertEquals($kalturaMock->captionsLanguage($link_url), 2); + $this->assertEquals($kaltura->captionsLanguage($response), 2); } - public function testCaptionsLanguageFailureEmpty() + public function testCaptionsLanguageEmpty() { - $link_url = $this->test_url; - $json = '{ + $kaltura = new Kaltura('en', 'testApiKey', 'testEmail'); + $response = json_decode('{ "objects": [], "totalCount": 0, "objectType": "KalturaCaptionAssetListResponse" - }'; - - $kalturaMock = $this->getMockBuilder(Kaltura::class) - ->setConstructorArgs(['en', 'testApiKey', 'testEmail']) - ->onlyMethods(array('getVideoData')) - ->getMock(); + }'); - $kalturaMock->expects($this->once()) - ->method('getVideoData') - ->will($this->returnValue(json_decode($json))); - - $this->assertEquals($kalturaMock->captionsLanguage($link_url), 0); + $this->assertEquals($kaltura->captionsLanguage($response), 2); } - public function testCaptionsLanguageFailureWrongLanguage() + public function testCaptionsLanguageWrongLanguage() { - $link_url = $this->test_url; - $json = '{ + $kaltura = new Kaltura('en', 'testApiKey', 'testEmail'); + $response = json_decode('{ "objects": [ { "languageCode": "es" @@ -135,24 +71,31 @@ public function testCaptionsLanguageFailureWrongLanguage() ], "totalCount": 0, "objectType": "KalturaCaptionAssetListResponse" - }'; + }'); - $kalturaMock = $this->getMockBuilder(Kaltura::class) - ->setConstructorArgs(['en', 'testApiKey', 'testEmail']) - ->onlyMethods(array('getVideoData')) - ->getMock(); + $this->assertEquals($kaltura->captionsLanguage($response), 0); + } - $kalturaMock->expects($this->once()) - ->method('getVideoData') - ->will($this->returnValue(json_decode($json))); + public function testCaptionsLanguageWrongLanguageInverse() + { + $kaltura = new Kaltura('es', 'testApiKey', 'testEmail'); + $response = json_decode('{ + "objects": [ + { + "languageCode": "en" + } + ], + "totalCount": 0, + "objectType": "KalturaCaptionAssetListResponse" + }'); - $this->assertEquals($kalturaMock->captionsLanguage($link_url), 0); + $this->assertEquals($kaltura->captionsLanguage($response), 0); } - public function testCaptionsLanguageFailureWrongLanguageInverse() + public function testCaptionsNoLanguage() { - $link_url = $this->test_url; - $json = '{ + $kaltura = new Kaltura('', 'testApiKey', 'testEmail'); + $response = json_decode('{ "objects": [ { "languageCode": "en" @@ -160,18 +103,25 @@ public function testCaptionsLanguageFailureWrongLanguageInverse() ], "totalCount": 0, "objectType": "KalturaCaptionAssetListResponse" - }'; + }'); - $kalturaMock = $this->getMockBuilder(Kaltura::class) - ->setConstructorArgs(['es', 'testApiKey', 'testEmail']) - ->onlyMethods(array('getVideoData')) - ->getMock(); + $this->assertEquals($kaltura->captionsLanguage($response), 2); + } - $kalturaMock->expects($this->once()) - ->method('getVideoData') - ->will($this->returnValue(json_decode($json))); + public function testCaptionsNoLanguageFailure() + { + $kaltura = new Kaltura('', 'testApiKey', 'testEmail'); + $response = json_decode('{ + "objects": [ + { + "languageCode": "es" + } + ], + "totalCount": 0, + "objectType": "KalturaCaptionAssetListResponse" + }'); - $this->assertEquals($kalturaMock->captionsLanguage($link_url), 0); + $this->assertEquals($kaltura->captionsLanguage($response), 0); } } \ No newline at end of file diff --git a/tests/VideoCaptionsMatchCourseLanguageTest.php b/tests/VideoCaptionsMatchCourseLanguageTest.php deleted file mode 100644 index f852a34..0000000 --- a/tests/VideoCaptionsMatchCourseLanguageTest.php +++ /dev/null @@ -1,118 +0,0 @@ -Valid Link'; - $dom = new \DOMDocument('1.0', 'utf-8'); - $dom->loadHTML($html); - $options = [ - 'vimeoApiKey' => 'test', - 'youtubeApiKey' => 'test', - 'kalturaApiKey' => 'test', - 'kalturaUsername' => 'test' - ]; - - $ruleMock = $this->getMockBuilder(VideoCaptionsMatchCourseLanguage::class) - ->setConstructorArgs([$dom, $options]) - ->setMethods(array('getCaptionState')) - ->getMock(); - - $ruleMock->expects($this->once()) - ->method('getCaptionState') - ->will($this->returnValue(0)); - - $this->assertEquals(1, $ruleMock->check()); - } - - public function testCheckNoIssuesRightLanguage() - { - $html = '
Valid Link
'; - $dom = new \DOMDocument('1.0', 'utf-8'); - $dom->loadHTML($html); - $options = [ - 'vimeoApiKey' => 'test', - 'youtubeApiKey' => 'test', - 'kalturaApiKey' => 'test', - 'kalturaUsername' => 'test' - ]; - - $ruleMock = $this->getMockBuilder(VideoCaptionsMatchCourseLanguage::class) - ->setConstructorArgs([$dom, $options]) - ->setMethods(array('getCaptionState')) - ->getMock(); - - $ruleMock->expects($this->once()) - ->method('getCaptionState') - ->will($this->returnValue(2)); - - $this->assertEquals(0, $ruleMock->check()); - } - - public function testCheckNoIssuesVimeo() - { - $html = '
Valid Link
'; - $dom = new \DOMDocument('1.0', 'utf-8'); - $dom->loadHTML($html); - $options = [ - 'vimeoApiKey' => 'bef37736cfb26b6dc52986d8f531d0ad', - 'youtubeApiKey' => 'AIzaSyB5bTf8rbYwiM73k1rj8dDnwEalwTqdz_c' - ]; - $ruleMock = $this->getMockBuilder(VideoCaptionsMatchCourseLanguage::class) - ->setConstructorArgs([$dom, $options]) - ->setMethods(array('getCaptionState')) - ->getMock(); - - $ruleMock->expects($this->once()) - ->method('getCaptionState') - ->will($this->returnValue(2)); - - $this->assertEquals(0, $ruleMock->check()); - } - - public function testCheckNoIssuesKaltura() - { - $html = '
Valid Link
'; - $dom = new \DOMDocument('1.0', 'utf-8'); - $dom->loadHTML($html); - $options = [ - 'vimeoApiKey' => 'bef37736cfb26b6dc52986d8f531d0ad', - 'youtubeApiKey' => 'AIzaSyB5bTf8rbYwiM73k1rj8dDnwEalwTqdz_c' - ]; - $ruleMock = $this->getMockBuilder(VideoCaptionsMatchCourseLanguage::class) - ->setConstructorArgs([$dom, $options]) - ->setMethods(array('getCaptionState')) - ->getMock(); - - $ruleMock->expects($this->once()) - ->method('getCaptionState') - ->will($this->returnValue(2)); - - $this->assertEquals(0, $ruleMock->check()); - } - - public function testCheckNoIssuesUnsupportedSite() - { - $html = '
Valid Link
'; - $dom = new \DOMDocument('1.0', 'utf-8'); - $dom->loadHTML($html); - $options = [ - 'vimeoApiKey' => 'bef37736cfb26b6dc52986d8f531d0ad', - 'youtubeApiKey' => 'AIzaSyB5bTf8rbYwiM73k1rj8dDnwEalwTqdz_c' - ]; - $ruleMock = $this->getMockBuilder(VideoCaptionsMatchCourseLanguage::class) - ->setConstructorArgs([$dom, $options]) - ->setMethods(array('getCaptionState')) - ->getMock(); - - $ruleMock->expects($this->once()) - ->method('getCaptionState') - ->will($this->returnValue(2)); - - $this->assertEquals(0, $ruleMock->check()); - } - - -} \ No newline at end of file diff --git a/tests/VideoScanTest.php b/tests/VideoScanTest.php new file mode 100644 index 0000000..5452387 --- /dev/null +++ b/tests/VideoScanTest.php @@ -0,0 +1,118 @@ +'; + $dom = new \DOMDocument('1.0', 'utf-8'); + $dom->loadHTML($html); + $options = [ + 'vimeoApiKey' => 'test', + 'youtubeApiKey' => 'test', + 'kalturaApiKey' => 'test', + 'kalturaUsername' => 'test' + ]; + $string = '{ + "items": [] + }'; + $response = new Response(200, ['Content-Type' => 'application/json'], $string); + + $ruleMock = $this->getMockBuilder(VideoScan::class) + ->setConstructorArgs([$dom, $options]) + ->setMethods(array('getCaptionData')) + ->getMock(); + + $ruleMock->expects($this->once()) + ->method('getCaptionData') + ->will($this->returnValue($response)); + + $this->assertEquals(1, $ruleMock->check()); + } + + public function testCheckEmptyVimeo() + { + $html = ''; + $dom = new \DOMDocument('1.0', 'utf-8'); + $dom->loadHTML($html); + $options = [ + 'vimeoApiKey' => 'test', + 'youtubeApiKey' => 'test', + 'kalturaApiKey' => 'test', + 'kalturaUsername' => 'test' + ]; + $string = '{ + "total": 0, + "data": [] + }'; + $response = new Response(200, ['Content-Type' => 'application/json'], $string); + + $ruleMock = $this->getMockBuilder(VideoScan::class) + ->setConstructorArgs([$dom, $options]) + ->setMethods(array('getCaptionData')) + ->getMock(); + + $ruleMock->expects($this->once()) + ->method('getCaptionData') + ->will($this->returnValue($response)); + + $this->assertEquals(1, $ruleMock->check()); + } + + public function testCheckEmptyKaltura() + { + $html = ''; + $dom = new \DOMDocument('1.0', 'utf-8'); + $dom->loadHTML($html); + $options = [ + 'vimeoApiKey' => 'test', + 'youtubeApiKey' => 'test', + 'kalturaApiKey' => 'test', + 'kalturaUsername' => 'test' + ]; + $response = json_decode('{ + "objects": [], + "totalCount": 0, + "objectType": "KalturaCaptionAssetListResponse" + }'); + + $ruleMock = $this->getMockBuilder(VideoScan::class) + ->setConstructorArgs([$dom, $options]) + ->setMethods(array('getCaptionData')) + ->getMock(); + + $ruleMock->expects($this->once()) + ->method('getCaptionData') + ->will($this->returnValue($response)); + + $this->assertEquals(1, $ruleMock->check()); + } + + public function testCheckNoApiKey() + { + $html = ['', + '', '
Valid Link
']; + $options = [ + 'vimeoApiKey' => '', + 'youtubeApiKey' => '', + 'kalturaApiKey' => '', + 'kalturaUsername' => '' + ]; + foreach ($html as $video) { + $dom = new \DOMDocument('1.0', 'utf-8'); + $dom->loadHTML($video); + + $ruleMock = $this->getMockBuilder(VideoScan::class) + ->setConstructorArgs([$dom, $options]) + ->getMock(); + + $this->assertEquals(0, $ruleMock->check()); + } + } +} \ No newline at end of file diff --git a/tests/VideosEmbdeddedOrLinkedNeedCaptionsTest.php b/tests/VideosEmbdeddedOrLinkedNeedCaptionsTest.php deleted file mode 100644 index ae010e3..0000000 --- a/tests/VideosEmbdeddedOrLinkedNeedCaptionsTest.php +++ /dev/null @@ -1,56 +0,0 @@ - - '; - $dom = new \DOMDocument('1.0', 'utf-8'); - $dom->loadHTML($html); - $options = [ - 'vimeoApiKey' => 'test', - 'youtubeApiKey' => 'test', - 'kalturaApiKey' => 'test', - 'kalturaUsername' => 'test' - ]; - - $ruleMock = $this->getMockBuilder(VideosEmbeddedOrLinkedNeedCaptions::class) - ->setConstructorArgs([$dom, $options]) - ->setMethods(array('getCaptionState')) - ->getMock(); - - $ruleMock->expects($this->exactly(2)) - ->method('getCaptionState') - ->will($this->returnValue(0)); - - $this->assertEquals(2, $ruleMock->check()); - } - - public function testCaptionsMissingHasCaptions() - { - $html = ' - '; - $dom = new \DOMDocument('1.0', 'utf-8'); - $dom->loadHTML($html); - $options = [ - 'vimeoApiKey' => 'test', - 'youtubeApiKey' => 'test', - 'kalturaApiKey' => 'test', - 'kalturaUsername' => 'test' - ]; - - $ruleMock = $this->getMockBuilder(VideosEmbeddedOrLinkedNeedCaptions::class) - ->setConstructorArgs([$dom, $options]) - ->setMethods(array('getCaptionState')) - ->getMock(); - - $ruleMock->expects($this->exactly(2)) - ->method('getCaptionState') - ->will($this->returnValue(2)); - - $this->assertEquals(0, $ruleMock->check()); - } -} \ No newline at end of file diff --git a/tests/VideosHaveAutoGeneratedCaptionsTest.php b/tests/VideosHaveAutoGeneratedCaptionsTest.php deleted file mode 100644 index d317d53..0000000 --- a/tests/VideosHaveAutoGeneratedCaptionsTest.php +++ /dev/null @@ -1,54 +0,0 @@ -'; - $dom = new \DOMDocument('1.0', 'utf-8'); - $dom->loadHTML($html); - $options = [ - 'vimeoApiKey' => 'test', - 'youtubeApiKey' => 'test', - 'kalturaApiKey' => 'test', - 'kalturaUsername' => 'test' - ]; - - $ruleMock = $this->getMockBuilder(VideosHaveAutoGeneratedCaptions::class) - ->setConstructorArgs([$dom, $options]) - ->setMethods(array('getCaptionState')) - ->getMock(); - - $ruleMock->expects($this->once()) - ->method('getCaptionState') - ->will($this->returnValue(0)); - - $this->assertEquals(1, $ruleMock->check()); - } - - public function testCaptionsMissingHasCaptions() - { - $html = ''; - $dom = new \DOMDocument('1.0', 'utf-8'); - $dom->loadHTML($html); - $options = [ - 'vimeoApiKey' => 'test', - 'youtubeApiKey' => 'test', - 'kalturaApiKey' => 'test', - 'kalturaUsername' => 'test' - ]; - - $ruleMock = $this->getMockBuilder(VideosHaveAutoGeneratedCaptions::class) - ->setConstructorArgs([$dom, $options]) - ->setMethods(array('getCaptionState')) - ->getMock(); - - $ruleMock->expects($this->once()) - ->method('getCaptionState') - ->will($this->returnValue(2)); - - $this->assertEquals(0, $ruleMock->check(), 'Youtube Test should return 0 failed tests to indicate no missing captions'); - } -} \ No newline at end of file diff --git a/tests/VimeoTest.php b/tests/VimeoTest.php index af101c8..8525b10 100644 --- a/tests/VimeoTest.php +++ b/tests/VimeoTest.php @@ -1,99 +1,93 @@ link_url; $client = new \GuzzleHttp\Client(['http_errors' => false]); $string = '{ "total": 0, "data": [] }'; - $response = new Response(200, ['Content-Type' => 'application/json'], $string); - $vimeoMock = $this->getMockBuilder(Vimeo::class) - ->setConstructorArgs([$client, 'en', 'testApiKey']) - ->onlyMethods(array('getVideoData')) - ->getMock(); - - $vimeoMock->expects($this->once()) - ->method('getVideoData') - ->will($this->returnValue($response)); + $vimeo = new Vimeo($client, 'en', 'testApikey'); + $response = new Response(200, ['Content-Type' => 'application/json'], $string); - $this->assertEquals($vimeoMock->captionsMissing($link_url), 0); + $this->assertEquals($vimeo->captionsMissing($response), 0); } public function testCaptionsMissingHasCaptions() { - $link_url = $this->link_url; $client = new \GuzzleHttp\Client(['http_errors' => false]); $string = '{ "total": 2, "data": [{"language": "en"}, {"language": "es"}] }'; - $response = new Response(200, ['Content-Type' => 'application/json'], $string); - - $vimeoMock = $this->getMockBuilder(Vimeo::class) - ->setConstructorArgs([$client, 'en', 'testApiKey']) - ->onlyMethods(array('getVideoData')) - ->getMock(); - $vimeoMock->expects($this->once()) - ->method('getVideoData') - ->will($this->returnValue($response)); + $vimeo = new Vimeo($client, 'en', 'testApikey'); + $response = new Response(200, ['Content-Type' => 'application/json'], $string); - $this->assertEquals($vimeoMock->captionsMissing($link_url), 2); + $this->assertEquals($vimeo->captionsMissing($response), 2); } public function testCaptionsLanguage() { - $link_url = $this->link_url; $client = new \GuzzleHttp\Client(['http_errors' => false]); $string = '{ "total": 1, "data": [{"language": "en"}] }'; - $response = new Response(200, ['Content-Type' => 'application/json'], $string); - $vimeoMock = $this->getMockBuilder(Vimeo::class) - ->setConstructorArgs([$client, 'en', 'testApiKey']) - ->onlyMethods(array('getVideoData')) - ->getMock(); - - $vimeoMock->expects($this->once()) - ->method('getVideoData') - ->will($this->returnValue($response)); + $vimeo = new Vimeo($client, 'en', 'testApikey'); + $response = new Response(200, ['Content-Type' => 'application/json'], $string); - $this->assertEquals($vimeoMock->captionsLanguage($link_url), 2); + $this->assertEquals($vimeo->captionsLanguage($response), 2); } public function testCaptionsLanguageFailure() { - $link_url = $this->link_url; $client = new \GuzzleHttp\Client(['http_errors' => false]); $string = '{ "total": 1, "data": [{"language": "es"}] }'; + + $vimeo = new Vimeo($client, 'en', 'testApikey'); $response = new Response(200, ['Content-Type' => 'application/json'], $string); - $vimeoMock = $this->getMockBuilder(Vimeo::class) - ->setConstructorArgs([$client, 'en', 'testApiKey']) - ->onlyMethods(array('getVideoData')) - ->getMock(); + $this->assertEquals($vimeo->captionsLanguage($response), 0); + } - $vimeoMock->expects($this->once()) - ->method('getVideoData') - ->will($this->returnValue($response)); + public function testCaptionsNoLanguage() + { + $client = new \GuzzleHttp\Client(['http_errors' => false]); + $string = '{ + "total": 1, + "data": [{"language": "en"}] + }'; + + $vimeo = new Vimeo($client, '', 'testApikey'); + $response = new Response(200, ['Content-Type' => 'application/json'], $string); + + $this->assertEquals($vimeo->captionsLanguage($response), 2); + } + + public function testCaptionsNoLanguageFailure() + { + $client = new \GuzzleHttp\Client(['http_errors' => false]); + $string = '{ + "total": 1, + "data": [{"language": "es"}] + }'; + + $vimeo = new Vimeo($client, '', 'testApikey'); + $response = new Response(200, ['Content-Type' => 'application/json'], $string); - $this->assertEquals($vimeoMock->captionsLanguage($link_url), 0); + $this->assertEquals($vimeo->captionsLanguage($response), 0); } diff --git a/tests/YoutubeTest.php b/tests/YoutubeTest.php index 1e3bfef..5dbcef7 100644 --- a/tests/YoutubeTest.php +++ b/tests/YoutubeTest.php @@ -1,37 +1,26 @@ link_url; $client = new \GuzzleHttp\Client(['http_errors' => false]); $string = '{ "items": [] }'; - $response = new Response(200, ['Content-Type' => 'application/json'], $string); - - $youtubeMock = $this->getMockBuilder(Youtube::class) - ->setConstructorArgs([$client, 'en', 'testApiKey']) - ->onlyMethods(array('getVideoData')) - ->getMock(); - $youtubeMock->expects($this->once()) - ->method('getVideoData') - ->will($this->returnValue($response)); + $youtube = new Youtube($client, 'en', 'testApiKey'); + $response = new Response(200, ['Content-Type' => 'application/json'], $string); - $this->assertEquals($youtubeMock->captionsMissing($link_url), 0); + $this->assertEquals($youtube->captionsMissing($response), 0); } public function testCaptionsMissingHasCaptions() { - $link_url = $this->link_url; $client = new \GuzzleHttp\Client(['http_errors' => false]); $string = '{ "items": [ @@ -49,22 +38,14 @@ public function testCaptionsMissingHasCaptions() } ] }'; - $response = new Response(200, ['Content-Type' => 'application/json'], $string); - $youtubeMock = $this->getMockBuilder(Youtube::class) - ->setConstructorArgs([$client, 'en', 'testApiKey']) - ->onlyMethods(array('getVideoData')) - ->getMock(); - - $youtubeMock->expects($this->once()) - ->method('getVideoData') - ->will($this->returnValue($response)); + $youtube = new Youtube($client, 'en', 'testApiKey'); + $response = new Response(200, ['Content-Type' => 'application/json'], $string); - $this->assertEquals($youtubeMock->captionsMissing($link_url), 2); + $this->assertEquals($youtube->captionsMissing($response), 2); } public function testCaptionsLanguageFail(){ - $link_url = $this->link_url; $client = new \GuzzleHttp\Client(['http_errors' => false]); $string = '{ "items": [ @@ -82,22 +63,51 @@ public function testCaptionsLanguageFail(){ } ] }'; + + $youtube = new Youtube($client, 'en', 'testApiKey'); $response = new Response(200, ['Content-Type' => 'application/json'], $string); - $youtubeMock = $this->getMockBuilder(Youtube::class) - ->setConstructorArgs([$client, 'en', 'testApiKey']) - ->onlyMethods(array('getVideoData')) - ->getMock(); + $this->assertEquals($youtube->captionsLanguage($response), 0); + } - $youtubeMock->expects($this->once()) - ->method('getVideoData') - ->will($this->returnValue($response)); + public function testCaptionsLanguageSuccess(){ + $client = new \GuzzleHttp\Client(['http_errors' => false]); + $string = '{ + "items": [ + { + "snippet": { + "trackKind": "standard", + "language": "en" + } + }, + { + "snippet": { + "trackKind": "standard", + "language": "es-419" + } + } + ] + }'; + + $youtube = new Youtube($client, 'en', 'testApiKey'); + $response = new Response(200, ['Content-Type' => 'application/json'], $string); - $this->assertEquals($youtubeMock->captionsLanguage($link_url), 0); + $this->assertEquals($youtube->captionsLanguage($response), 2); } - public function testCaptionsLanguageSuccess(){ - $link_url = $this->link_url; + public function testCaptionsLanguageEmpty(){ + $client = new \GuzzleHttp\Client(['http_errors' => false]); + $string = '{ + "items": [] + }'; + + $youtube = new Youtube($client, 'en', 'testApiKey'); + $response = new Response(200, ['Content-Type' => 'application/json'], $string); + + $this->assertEquals($youtube->captionsLanguage($response), 2); + } + + public function testCaptionsNoLanguage(){ $client = new \GuzzleHttp\Client(['http_errors' => false]); $string = '{ "items": [ @@ -115,22 +125,39 @@ public function testCaptionsLanguageSuccess(){ } ] }'; + + $youtube = new Youtube($client, '', 'testApiKey'); $response = new Response(200, ['Content-Type' => 'application/json'], $string); - $youtubeMock = $this->getMockBuilder(Youtube::class) - ->setConstructorArgs([$client, 'en', 'testApiKey']) - ->onlyMethods(array('getVideoData')) - ->getMock(); + $this->assertEquals($youtube->captionsLanguage($response), 2); + } + + public function testCaptionsNoLanguageFailure(){ + $client = new \GuzzleHttp\Client(['http_errors' => false]); + $string = '{ + "items": [ + { + "snippet": { + "trackKind": "standard", + "language": "de" + } + }, + { + "snippet": { + "trackKind": "standard", + "language": "es-419" + } + } + ] + }'; - $youtubeMock->expects($this->once()) - ->method('getVideoData') - ->will($this->returnValue($response)); + $youtube = new Youtube($client, '', 'testApiKey'); + $response = new Response(200, ['Content-Type' => 'application/json'], $string); - $this->assertEquals($youtubeMock->captionsLanguage($link_url), 2); + $this->assertEquals($youtube->captionsLanguage($response), 0); } public function testCaptionsAutoGeneratedFailure(){ - $link_url = $this->link_url; $client = new \GuzzleHttp\Client(['http_errors' => false]); $string = '{ "items": [ @@ -142,22 +169,14 @@ public function testCaptionsAutoGeneratedFailure(){ } ] }'; - $response = new Response(200, ['Content-Type' => 'application/json'], $string); - - $youtubeMock = $this->getMockBuilder(Youtube::class) - ->setConstructorArgs([$client, 'en', 'testApiKey']) - ->onlyMethods(array('getVideoData')) - ->getMock(); - $youtubeMock->expects($this->once()) - ->method('getVideoData') - ->will($this->returnValue($response)); + $youtube = new Youtube($client, 'en', 'testApiKey'); + $response = new Response(200, ['Content-Type' => 'application/json'], $string); - $this->assertEquals($youtubeMock->captionsAutoGenerated($link_url), 0); + $this->assertEquals($youtube->captionsAutoGenerated($response), 0); } public function testCaptionsAutoGeneratedSuccess(){ - $link_url = $this->link_url; $client = new \GuzzleHttp\Client(['http_errors' => false]); $string = '{ "items": [ @@ -175,18 +194,11 @@ public function testCaptionsAutoGeneratedSuccess(){ } ] }'; - $response = new Response(200, ['Content-Type' => 'application/json'], $string); - $youtubeMock = $this->getMockBuilder(Youtube::class) - ->setConstructorArgs([$client, 'en', 'testApiKey']) - ->onlyMethods(array('getVideoData')) - ->getMock(); - - $youtubeMock->expects($this->once()) - ->method('getVideoData') - ->will($this->returnValue($response)); + $youtube = new Youtube($client, 'en', 'testApiKey'); + $response = new Response(200, ['Content-Type' => 'application/json'], $string); - $this->assertEquals($youtubeMock->captionsAutoGenerated($link_url), 2); + $this->assertEquals($youtube->captionsAutoGenerated($response), 2); } } \ No newline at end of file