diff --git a/language/src/analyze_all.php b/language/src/analyze_all.php index 1d92bc8640..46e43585fb 100644 --- a/language/src/analyze_all.php +++ b/language/src/analyze_all.php @@ -21,13 +21,7 @@ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/language/README.md */ -// Include Google Cloud dependendencies using Composer -require_once __DIR__ . '/../vendor/autoload.php'; - -if (count($argv) != 2) { - return printf("Usage: php %s TEXT\n", __FILE__); -} -list($_, $text) = $argv; +namespace Google\Cloud\Samples\Language; # [START analyze_all] use Google\Cloud\Language\V1\AnnotateTextRequest\Features; @@ -38,13 +32,14 @@ use Google\Cloud\Language\V1\EntityMention\Type as MentionType; use Google\Cloud\Language\V1\PartOfSpeech\Tag; -/** Uncomment and populate these variables in your code */ -// $text = 'The text to analyze.'; - -// Create the Natural Language client -$languageServiceClient = new LanguageServiceClient(); +/** + * @param string $text The text to analyze + */ +function analyze_all(string $text): void +{ + // Create the Natural Language client + $languageServiceClient = new LanguageServiceClient(); -try { // Create a new Document, pass text and set type to PLAIN_TEXT $document = (new Document()) ->setContent($text) @@ -105,7 +100,9 @@ printf('Token part of speech: %s' . PHP_EOL, Tag::name($token->getPartOfSpeech()->getTag())); printf(PHP_EOL); } -} finally { - $languageServiceClient->close(); } # [END analyze_all] + +// The following 2 lines are only needed to run the samples +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/language/src/analyze_all_from_file.php b/language/src/analyze_all_from_file.php index c42b4e3cf3..0bd1d0ced8 100644 --- a/language/src/analyze_all_from_file.php +++ b/language/src/analyze_all_from_file.php @@ -21,13 +21,7 @@ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/language/README.md */ -// Include Google Cloud dependendencies using Composer -require_once __DIR__ . '/../vendor/autoload.php'; - -if (count($argv) != 2) { - return printf("Usage: php %s FILE\n", __FILE__); -} -list($_, $uri) = $argv; +namespace Google\Cloud\Samples\Language; # [START analyze_all_from_file] use Google\Cloud\Language\V1\AnnotateTextRequest\Features; @@ -38,12 +32,14 @@ use Google\Cloud\Language\V1\EntityMention\Type as MentionType; use Google\Cloud\Language\V1\PartOfSpeech\Tag; -/** Uncomment and populate these variables in your code */ -// $uri = 'The cloud storage object to analyze (gs://your-bucket-name/your-object-name)'; +/** + * @param string $uri The cloud storage object to analyze (gs://your-bucket-name/your-object-name) + */ +function analyze_all_from_file(string $uri): void +{ + // Create the Natural Language client + $languageServiceClient = new LanguageServiceClient(); -// Create the Natural Language client -$languageServiceClient = new LanguageServiceClient(); -try { // Create a new Document, pass GCS URI and set type to PLAIN_TEXT $document = (new Document()) ->setGcsContentUri($uri) @@ -109,7 +105,9 @@ printf('Token part of speech: %s' . PHP_EOL, Tag::name($token->getPartOfSpeech()->getTag())); printf(PHP_EOL); } -} finally { - $languageServiceClient->close(); } # [END analyze_all_from_file] + +// The following 2 lines are only needed to run the samples +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/language/src/analyze_entities.php b/language/src/analyze_entities.php index 21abaf9e62..c615601222 100644 --- a/language/src/analyze_entities.php +++ b/language/src/analyze_entities.php @@ -21,13 +21,7 @@ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/language/README.md */ -// Include Google Cloud dependendencies using Composer -require_once __DIR__ . '/../vendor/autoload.php'; - -if (count($argv) != 2) { - return printf("Usage: php %s TEXT\n", __FILE__); -} -list($_, $text) = $argv; +namespace Google\Cloud\Samples\Language; # [START language_entities_text] use Google\Cloud\Language\V1\Document; @@ -35,12 +29,14 @@ use Google\Cloud\Language\V1\LanguageServiceClient; use Google\Cloud\Language\V1\Entity\Type as EntityType; -/** Uncomment and populate these variables in your code */ -// $text = 'The text to analyze.'; +/** + * @param string $text The text to analyze + */ +function analyze_entities(string $text): void +{ + // Create the Natural Language client + $languageServiceClient = new LanguageServiceClient(); -// Create the Natural Language client -$languageServiceClient = new LanguageServiceClient(); -try { // Create a new Document, add text as content and set type to PLAIN_TEXT $document = (new Document()) ->setContent($text) @@ -62,7 +58,9 @@ } printf(PHP_EOL); } -} finally { - $languageServiceClient->close(); } # [END language_entities_text] + +// The following 2 lines are only needed to run the samples +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/language/src/analyze_entities_from_file.php b/language/src/analyze_entities_from_file.php index 271e16ac1d..0c086d0ea7 100644 --- a/language/src/analyze_entities_from_file.php +++ b/language/src/analyze_entities_from_file.php @@ -21,13 +21,7 @@ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/language/README.md */ -// Include Google Cloud dependendencies using Composer -require_once __DIR__ . '/../vendor/autoload.php'; - -if (count($argv) != 2) { - return printf("Usage: php %s FILE\n", __FILE__); -} -list($_, $uri) = $argv; +namespace Google\Cloud\Samples\Language; # [START language_entities_gcs] use Google\Cloud\Language\V1\Document; @@ -35,12 +29,14 @@ use Google\Cloud\Language\V1\LanguageServiceClient; use Google\Cloud\Language\V1\Entity\Type as EntityType; -/** Uncomment and populate these variables in your code */ -// $uri = 'The cloud storage object to analyze (gs://your-bucket-name/your-object-name)'; +/** + * @param string $uri The cloud storage object to analyze (gs://your-bucket-name/your-object-name) + */ +function analyze_entities_from_file(string $uri): void +{ + // Create the Natural Language client + $languageServiceClient = new LanguageServiceClient(); -// Create the Natural Language client -$languageServiceClient = new LanguageServiceClient(); -try { // Create a new Document, pass GCS URI and set type to PLAIN_TEXT $document = (new Document()) ->setGcsContentUri($uri) @@ -62,7 +58,9 @@ } printf(PHP_EOL); } -} finally { - $languageServiceClient->close(); } # [END language_entities_gcs] + +// The following 2 lines are only needed to run the samples +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/language/src/analyze_entity_sentiment.php b/language/src/analyze_entity_sentiment.php index 9ee8905ae5..7bef5c1b98 100644 --- a/language/src/analyze_entity_sentiment.php +++ b/language/src/analyze_entity_sentiment.php @@ -21,13 +21,7 @@ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/language/README.md */ -// Include Google Cloud dependendencies using Composer -require_once __DIR__ . '/../vendor/autoload.php'; - -if (count($argv) != 2) { - return printf("Usage: php %s TEXT\n", __FILE__); -} -list($_, $text) = $argv; +namespace Google\Cloud\Samples\Language; # [START language_entity_sentiment_text] use Google\Cloud\Language\V1\Document; @@ -35,11 +29,13 @@ use Google\Cloud\Language\V1\LanguageServiceClient; use Google\Cloud\Language\V1\Entity\Type as EntityType; -/** Uncomment and populate these variables in your code */ -// $text = 'The text to analyze.'; +/** + * @param string $text The text to analyze + */ +function analyze_entity_sentiment(string $text): void +{ + $languageServiceClient = new LanguageServiceClient(); -$languageServiceClient = new LanguageServiceClient(); -try { // Create a new Document, add text as content and set type to PLAIN_TEXT $document = (new Document()) ->setContent($text) @@ -60,7 +56,9 @@ } print(PHP_EOL); } -} finally { - $languageServiceClient->close(); } # [END language_entity_sentiment_text] + +// The following 2 lines are only needed to run the samples +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/language/src/analyze_entity_sentiment_from_file.php b/language/src/analyze_entity_sentiment_from_file.php index 0d8e8e48f9..7f66334062 100644 --- a/language/src/analyze_entity_sentiment_from_file.php +++ b/language/src/analyze_entity_sentiment_from_file.php @@ -21,13 +21,7 @@ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/language/README.md */ -// Include Google Cloud dependendencies using Composer -require_once __DIR__ . '/../vendor/autoload.php'; - -if (count($argv) != 2) { - return printf("Usage: php %s FILE\n", __FILE__); -} -list($_, $uri) = $argv; +namespace Google\Cloud\Samples\Language; # [START language_entity_sentiment_gcs] use Google\Cloud\Language\V1\Document; @@ -35,12 +29,14 @@ use Google\Cloud\Language\V1\LanguageServiceClient; use Google\Cloud\Language\V1\Entity\Type as EntityType; -/** Uncomment and populate these variables in your code */ -// $uri = 'The cloud storage object to analyze (gs://your-bucket-name/your-object-name)'; +/** + * @param string $uri The cloud storage object to analyze (gs://your-bucket-name/your-object-name) + */ +function analyze_entity_sentiment_from_file(string $uri): void +{ + // Create the Natural Language client + $languageServiceClient = new LanguageServiceClient(); -// Create the Natural Language client -$languageServiceClient = new LanguageServiceClient(); -try { // Create a new Document, pass GCS URI and set type to PLAIN_TEXT $document = (new Document()) ->setGcsContentUri($uri) @@ -61,7 +57,9 @@ } print(PHP_EOL); } -} finally { - $languageServiceClient->close(); } # [END language_entity_sentiment_gcs] + +// The following 2 lines are only needed to run the samples +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/language/src/analyze_sentiment.php b/language/src/analyze_sentiment.php index 2451be597d..df71159641 100644 --- a/language/src/analyze_sentiment.php +++ b/language/src/analyze_sentiment.php @@ -21,24 +21,20 @@ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/language/README.md */ -// Include Google Cloud dependendencies using Composer -require_once __DIR__ . '/../vendor/autoload.php'; - -if (count($argv) != 2) { - return printf("Usage: php %s TEXT\n", __FILE__); -} -list($_, $text) = $argv; +namespace Google\Cloud\Samples\Language; # [START language_sentiment_text] use Google\Cloud\Language\V1\Document; use Google\Cloud\Language\V1\Document\Type; use Google\Cloud\Language\V1\LanguageServiceClient; -/** Uncomment and populate these variables in your code */ -// $text = 'The text to analyze.'; +/** + * @param string $text The text to analyze + */ +function analyze_sentiment(string $text): void +{ + $languageServiceClient = new LanguageServiceClient(); -$languageServiceClient = new LanguageServiceClient(); -try { // Create a new Document, add text as content and set type to PLAIN_TEXT $document = (new Document()) ->setContent($text) @@ -63,7 +59,9 @@ } print(PHP_EOL); } -} finally { - $languageServiceClient->close(); } # [END language_sentiment_text] + +// The following 2 lines are only needed to run the samples +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/language/src/analyze_sentiment_from_file.php b/language/src/analyze_sentiment_from_file.php index 023636ea59..ca3feda0a8 100644 --- a/language/src/analyze_sentiment_from_file.php +++ b/language/src/analyze_sentiment_from_file.php @@ -21,24 +21,20 @@ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/language/README.md */ -// Include Google Cloud dependendencies using Composer -require_once __DIR__ . '/../vendor/autoload.php'; - -if (count($argv) != 2) { - return printf("Usage: php %s FILE\n", __FILE__); -} -list($_, $uri) = $argv; +namespace Google\Cloud\Samples\Language; # [START language_sentiment_gcs] use Google\Cloud\Language\V1\Document; use Google\Cloud\Language\V1\Document\Type; use Google\Cloud\Language\V1\LanguageServiceClient; -/** Uncomment and populate these variables in your code */ -// $uri = 'The cloud storage object to analyze (gs://your-bucket-name/your-object-name)'; +/** + * @param string $uri The cloud storage object to analyze (gs://your-bucket-name/your-object-name) + */ +function analyze_sentiment_from_file(string $uri): void +{ + $languageServiceClient = new LanguageServiceClient(); -$languageServiceClient = new LanguageServiceClient(); -try { // Create a new Document, pass GCS URI and set type to PLAIN_TEXT $document = (new Document()) ->setGcsContentUri($uri) @@ -63,7 +59,9 @@ } print(PHP_EOL); } -} finally { - $languageServiceClient->close(); } # [END language_sentiment_gcs] + +// The following 2 lines are only needed to run the samples +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/language/src/analyze_syntax.php b/language/src/analyze_syntax.php index 76b7ebf360..1f9ebb7c54 100644 --- a/language/src/analyze_syntax.php +++ b/language/src/analyze_syntax.php @@ -21,13 +21,7 @@ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/language/README.md */ -// Include Google Cloud dependendencies using Composer -require_once __DIR__ . '/../vendor/autoload.php'; - -if (count($argv) != 2) { - return printf("Usage: php %s TEXT\n", __FILE__); -} -list($_, $text) = $argv; +namespace Google\Cloud\Samples\Language; # [START language_syntax_text] use Google\Cloud\Language\V1\Document; @@ -35,13 +29,14 @@ use Google\Cloud\Language\V1\LanguageServiceClient; use Google\Cloud\Language\V1\PartOfSpeech\Tag; -/** Uncomment and populate these variables in your code */ -// $text = 'The text to analyze.'; - -// Create the Natural Language client -$languageServiceClient = new LanguageServiceClient(); +/** + * @param string $text The text to analyze + */ +function analyze_syntax(string $text): void +{ + // Create the Natural Language client + $languageServiceClient = new LanguageServiceClient(); -try { // Create a new Document, add text as content and set type to PLAIN_TEXT $document = (new Document()) ->setContent($text) @@ -56,7 +51,9 @@ printf('Token part of speech: %s' . PHP_EOL, Tag::name($token->getPartOfSpeech()->getTag())); print(PHP_EOL); } -} finally { - $languageServiceClient->close(); } # [END language_syntax_text] + +// The following 2 lines are only needed to run the samples +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/language/src/analyze_syntax_from_file.php b/language/src/analyze_syntax_from_file.php index 4ac718b4c4..fb3e367820 100644 --- a/language/src/analyze_syntax_from_file.php +++ b/language/src/analyze_syntax_from_file.php @@ -21,13 +21,7 @@ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/language/README.md */ -// Include Google Cloud dependendencies using Composer -require_once __DIR__ . '/../vendor/autoload.php'; - -if (count($argv) != 2) { - return printf("Usage: php %s FILE\n", __FILE__); -} -list($_, $uri) = $argv; +namespace Google\Cloud\Samples\Language; # [START language_syntax_gcs] use Google\Cloud\Language\V1\Document; @@ -35,13 +29,14 @@ use Google\Cloud\Language\V1\LanguageServiceClient; use Google\Cloud\Language\V1\PartOfSpeech\Tag; -/** Uncomment and populate these variables in your code */ -// $uri = 'The cloud storage object to analyze (gs://your-bucket-name/your-object-name)'; - -// Create the Natural Language client -$languageServiceClient = new LanguageServiceClient(); +/** + * @param string $uri The cloud storage object to analyze (gs://your-bucket-name/your-object-name) + */ +function analyze_syntax_from_file(string $uri): void +{ + // Create the Natural Language client + $languageServiceClient = new LanguageServiceClient(); -try { // Create a new Document, pass GCS URI and set type to PLAIN_TEXT $document = (new Document()) ->setGcsContentUri($uri) @@ -56,7 +51,9 @@ printf('Token part of speech: %s' . PHP_EOL, Tag::name($token->getPartOfSpeech()->getTag())); print(PHP_EOL); } -} finally { - $languageServiceClient->close(); } # [END language_syntax_gcs] + +// The following 2 lines are only needed to run the samples +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/language/src/classify_text.php b/language/src/classify_text.php index 782736ceee..276f87392b 100644 --- a/language/src/classify_text.php +++ b/language/src/classify_text.php @@ -21,29 +21,25 @@ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/language/README.md */ -// Include Google Cloud dependendencies using Composer -require_once __DIR__ . '/../vendor/autoload.php'; - -if (count($argv) != 2) { - return printf("Usage: php %s TEXT\n", __FILE__); -} -list($_, $text) = $argv; +namespace Google\Cloud\Samples\Language; # [START language_classify_text] use Google\Cloud\Language\V1\Document; use Google\Cloud\Language\V1\Document\Type; use Google\Cloud\Language\V1\LanguageServiceClient; -/** Uncomment and populate these variables in your code */ -// $text = 'The text to analyze.'; +/** + * @param string $text The text to analyze + */ +function classify_text(string $text): void +{ + // Make sure we have enough words (20+) to call classifyText + if (str_word_count($text) < 20) { + printf('20+ words are required to classify text.' . PHP_EOL); + return; + } + $languageServiceClient = new LanguageServiceClient(); -// Make sure we have enough words (20+) to call classifyText -if (str_word_count($text) < 20) { - printf('20+ words are required to classify text.' . PHP_EOL); - return; -} -$languageServiceClient = new LanguageServiceClient(); -try { // Create a new Document, add text as content and set type to PLAIN_TEXT $document = (new Document()) ->setContent($text) @@ -58,7 +54,9 @@ printf('Confidence: %s' . PHP_EOL, $category->getConfidence()); print(PHP_EOL); } -} finally { - $languageServiceClient->close(); } # [END language_classify_text] + +// The following 2 lines are only needed to run the samples +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/language/src/classify_text_from_file.php b/language/src/classify_text_from_file.php index 36a55bef90..f122e212e9 100644 --- a/language/src/classify_text_from_file.php +++ b/language/src/classify_text_from_file.php @@ -21,24 +21,20 @@ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/language/README.md */ -// Include Google Cloud dependendencies using Composer -require_once __DIR__ . '/../vendor/autoload.php'; - -if (count($argv) != 2) { - return printf("Usage: php %s FILE\n", __FILE__); -} -list($_, $uri) = $argv; +namespace Google\Cloud\Samples\Language; # [START language_classify_gcs] use Google\Cloud\Language\V1\Document; use Google\Cloud\Language\V1\Document\Type; use Google\Cloud\Language\V1\LanguageServiceClient; -/** Uncomment and populate these variables in your code */ -// $uri = 'The cloud storage object to analyze (gs://your-bucket-name/your-object-name)'; +/** + * @param string $uri The cloud storage object to analyze (gs://your-bucket-name/your-object-name) + */ +function classify_text_from_file(string $uri): void +{ + $languageServiceClient = new LanguageServiceClient(); -$languageServiceClient = new LanguageServiceClient(); -try { // Create a new Document, pass GCS URI and set type to PLAIN_TEXT $document = (new Document()) ->setGcsContentUri($uri) @@ -53,7 +49,9 @@ printf('Confidence: %s' . PHP_EOL, $category->getConfidence()); print(PHP_EOL); } -} finally { - $languageServiceClient->close(); } # [END language_classify_gcs] + +// The following 2 lines are only needed to run the samples +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/language/test/languageTest.php b/language/test/languageTest.php index ff69f4c9f3..570b30e623 100644 --- a/language/test/languageTest.php +++ b/language/test/languageTest.php @@ -18,7 +18,6 @@ namespace Google\Cloud\Samples\Language\Tests; use Google\Cloud\TestUtils\TestTrait; -use Google\Cloud\TestUtils\ExecuteCommandTrait; use PHPUnit\Framework\TestCase; /** @@ -27,9 +26,6 @@ class languageTest extends TestCase { use TestTrait; - use ExecuteCommandTrait; - - private static $commandFile = __DIR__ . '/../language.php'; public function gcsFile() { @@ -41,7 +37,7 @@ public function gcsFile() public function testAnalyzeAll() { - $output = $this->runSnippet( + $output = $this->runFunctionSnippet( 'analyze_all', ['Barack Obama lives in Washington D.C.'] ); @@ -74,7 +70,7 @@ public function testAnalyzeAll() public function testAnalzeAllFromFile() { - $output = $this->runSnippet('analyze_all_from_file', [$this->gcsFile()]); + $output = $this->runFunctionSnippet('analyze_all_from_file', [$this->gcsFile()]); $this->assertStringContainsString('Name: Barack Obama', $output); $this->assertStringContainsString('Type: PERSON', $output); @@ -105,7 +101,7 @@ public function testAnalzeAllFromFile() public function testAnalyzeEntities() { - $output = $this->runSnippet('analyze_entities', [ + $output = $this->runFunctionSnippet('analyze_entities', [ 'Barack Obama lives in Washington D.C.' ]); $this->assertStringContainsString('Name: Barack Obama', $output); @@ -118,7 +114,7 @@ public function testAnalyzeEntities() public function testAnalyzeEntitiesFromFile() { - $output = $this->runSnippet('analyze_entities_from_file', [ + $output = $this->runFunctionSnippet('analyze_entities_from_file', [ $this->gcsFile() ]); $this->assertStringContainsString('Name: Barack Obama', $output); @@ -131,7 +127,7 @@ public function testAnalyzeEntitiesFromFile() public function testAnalyzeSentiment() { - $output = $this->runSnippet('analyze_sentiment', [ + $output = $this->runFunctionSnippet('analyze_sentiment', [ 'Barack Obama lives in Washington D.C.' ]); $this->assertStringContainsString('Document Sentiment:', $output); @@ -145,7 +141,7 @@ public function testAnalyzeSentiment() public function testAnalyzeSentimentFromFile() { - $output = $this->runSnippet('analyze_sentiment_from_file', [ + $output = $this->runFunctionSnippet('analyze_sentiment_from_file', [ $this->gcsFile() ]); $this->assertStringContainsString('Document Sentiment:', $output); @@ -159,7 +155,7 @@ public function testAnalyzeSentimentFromFile() public function testAnalyzeSyntax() { - $output = $this->runSnippet('analyze_syntax', [ + $output = $this->runFunctionSnippet('analyze_syntax', [ 'Barack Obama lives in Washington D.C.' ]); $this->assertStringContainsString('Token text: Barack', $output); @@ -178,7 +174,7 @@ public function testAnalyzeSyntax() public function testAnalyzeSyntaxFromFile() { - $output = $this->runSnippet('analyze_syntax_from_file', [ + $output = $this->runFunctionSnippet('analyze_syntax_from_file', [ $this->gcsFile() ]); $this->assertStringContainsString('Token text: Barack', $output); @@ -197,7 +193,7 @@ public function testAnalyzeSyntaxFromFile() public function testAnalyzeEntitySentiment() { - $output = $this->runSnippet('analyze_entity_sentiment', [ + $output = $this->runFunctionSnippet('analyze_entity_sentiment', [ 'Barack Obama lives in Washington D.C.' ]); $this->assertStringContainsString('Entity Name: Barack Obama', $output); @@ -211,7 +207,7 @@ public function testAnalyzeEntitySentiment() public function testAnalyzeEntitySentimentFromFile() { - $output = $this->runSnippet('analyze_entity_sentiment_from_file', [ + $output = $this->runFunctionSnippet('analyze_entity_sentiment_from_file', [ $this->gcsFile() ]); $this->assertStringContainsString('Entity Name: Barack Obama', $output); @@ -225,7 +221,7 @@ public function testAnalyzeEntitySentimentFromFile() public function testClassifyText() { - $output = $this->runSnippet('classify_text', [ + $output = $this->runFunctionSnippet('classify_text', [ 'The first two gubernatorial elections since President ' . 'Donald Trump took office went in favor of Democratic ' . 'candidates in Virginia and New Jersey.' @@ -236,7 +232,7 @@ public function testClassifyText() public function testClassifyTextFromFile() { - $output = $this->runSnippet('classify_text_from_file', [ + $output = $this->runFunctionSnippet('classify_text_from_file', [ $this->gcsFile() ]); $this->assertStringContainsString('Category Name: /News/Politics', $output);