GoogleCloudPlatform / php-docs-samples

A collection of samples that demonstrate how to call Google Cloud services from PHP.
http://cloud.google.com/php
Apache License 2.0
965 stars 1.03k forks source link

fix(Datastore): migrate insert sample to individual file #1911

Closed vishwarajanand closed 8 months ago

vishwarajanand commented 1 year ago

This PR migrates a single Datstore sample to individual file format. ref: b/138631070

Changes

  1. Removed autoload from composer.json to load new samples (existing tests will fail till then, so removed now to migrate samples one by one)
  2. Removed a particular sample from /datastore/api/src/functions/concepts.php
  3. Added the sample (with license information & removing the return statements) to its own file /datastore/api/src/<function_name>.php
  4. Added a print statement with an information specific to the sample, say some id, description string, etc
  5. Modified the sample test function in /datastore/api/test/ConceptsTest.php to assert on the sample's print statement.

Tests

  1. Ensure we have a GCP with Datastore enabled.
  2. Run tests:
    
    ➜  php-docs-samples git:(datastore_samples_migration) cd datastore/api                                                           
    ➜  api git:(datastore_samples_migration) ../../testing/vendor/bin/phpunit -c phpunit.xml.dist --filter="testInsert"                     
    PHPUnit 9.6.11 by Sebastian Bergmann and contributors.

Warning: XDEBUG_MODE=coverage or xdebug.mode=coverage has to be set

. 1 / 1 (100%)

Time: 00:00.309, Memory: 10.00 MB

OK (1 test, 1 assertion) ➜ api git:(datastore_samples_migration)

snippet-bot[bot] commented 1 year ago

Here is the summary of changes.

You are about to add 1 region tag. - [datastore/api/src/insert.php:20](https://github.com/GoogleCloudPlatform/php-docs-samples/blob/9e3de2044a7b5e450d2851a82d6f2ad968792caf/datastore/api/src/insert.php#L20), tag `datastore_insert`
You are about to delete 1 region tag. - [datastore/api/src/functions/concepts.php:89](https://github.com/GoogleCloudPlatform/php-docs-samples/blob/3438bdb407efb3a67e52b8d190e73d0f1fb6a7cc/datastore/api/src/functions/concepts.php#L89), tag `datastore_insert`

This comment is generated by snippet-bot. If you find problems with this result, please file an issue at: https://github.com/googleapis/repo-automation-bots/issues. To update this comment, add snippet-bot:force-run label or use the checkbox below:

bshaffer commented 1 year ago

Looks good but two thoughts:

Removed autoload from composer.json to load new samples (existing tests will fail till then, so removed now to migrate samples one by one

I see no changes to composer.json, so what is this referring to?

Also, we should do these all at once!

vishwarajanand commented 1 year ago

@bshaffer sure thing, @shivgautam will take care of it. The composer changes I had made are in this commit and I had to revert them to ensure a test pass. Once all such samples are migrated, we need to redo those as part of this PR.

shivgautam commented 8 months ago

Fixed as part of #1968