Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test the initial version of the app #6

Closed
forikal-uk opened this issue May 31, 2018 · 23 comments
Closed

Test the initial version of the app #6

forikal-uk opened this issue May 31, 2018 · 23 comments

Comments

@forikal-uk
Copy link
Collaborator

forikal-uk commented May 31, 2018

Goal

Test the initial version of the app

Why

Zoka123 has done a pull request so let's see it running and iron out any issues.

How

@forikal-uk
Copy link
Collaborator Author

forikal-uk commented May 31, 2018

Let's do the installation

https://github.com/zoka123/gsheet-to-xml/blob/master/DOCUMENTATION.md#installation

Note Make sure you're using at least PHP 7.1

Check my version of PHP

$ php -v
PHP 7.1.14 (cli) (built: Feb  7 2018 18:33:30) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

On my MacOS navigate to my projects folder

  • Clone this project
  • Run composer install
  • test the console app: php bin/console.php --help

Done.

The php bin/console.php --help suggest use the list command to list the commands.

$ php bin/console.php list
Console Tool

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  help                   Displays help for a command
  list                   Lists commands
 forikal
  forikal:gsheet-to-xml  Convert GSheet file to XML

So, that shows our command as:

 forikal
  forikal:gsheet-to-xml  Convert GSheet file to XML

@forikal-uk
Copy link
Collaborator Author

forikal-uk commented May 31, 2018

Sort out the G API connections

Google API Setup

Interesting I did not realise you could do that on free Gmail. You can.

  • Click Enable APIs and enable
    • the Google Sheets API, and
    • the Google Drive API

Done.

  • Go to Credentials, then

  • click Create credentials, and

  • select Service account key

  • Choose New service account in the drop down.

  • Give the account a name, anything is fine

  • For Role I selected Project -> Editor

  • For Key type, choose JSON (the default),

  • Click Create, and

  • Download the file. This file contains a private key so be very careful with it, it is your credentials after all. Content of the file should be similar to our sample: client_secret.json.dist.

Done.

Where is the recommended place to put that highly sensitive file??? I guess I store it in my home directory maybe. The 'Learn more' prompt links through to: Understanding Service Accounts > Managing service account keys. It has lots of recommendations on how to manage the files.

  • Finally, edit the sharing permissions for the spreadsheet you want to access and share either View
    (if you only want to read the file) or Edit (if you need read/write) access to the client_email address you can find in the JSON file.

Done.


I saved the secret in my home folder:

/Users/x/APIKeys/gsheet-to-xml-e5eaf708560f.json

I took screen grab of the steps as I went along.
I saved them in: /Users/x/Documents/Capture/Tutorials/Forikal-gsheet-to-xml/api-setup

@forikal-uk
Copy link
Collaborator Author

Usage

php bin/console.php forikal:gsheet-to-xml {URL} [--credentials=client_secret.json]

{URL} should be either Drive or Sheets URL in one of following formats

@forikal-uk
Copy link
Collaborator Author

forikal-uk commented May 31, 2018

Let's try it.

First, I tried with the absolute path to the client_secret. We got a beautiful error to say credentials could not be found. Good to see nice error handling.

Then, I tried it with a relative path from the current working directory to a Google Sheet. This worked a beaut! Lovely!

$ pwd
/Users/x/Documents/Projects/XmlAuthoring/gsheet-to-xml
$ php bin/console.php forikal:gsheet-to-xml https://docs.google.com/spreadsheets/d/1_SnGKyXjHnsdylZw_YYIQ8HuxYQI-hsvxYQpftGMjpM/edit#gid=311423522 --credentials=../../../../APIKeys/gsheet-to-xml-e5eaf708560f.json
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Products>
  <Product>
    <Inventory src-sheet="https://docs.google.com/spreadsheets/d/1_SnGKyXjHnsdylZw_YYIQ8HuxYQI-hsvxYQpftGMjpM/edit#gid=311423522" src-tab="InventoryTab">
      <StockItem>
        <KNumberExists>true</KNumberExists>
        <KNumber>1111111</KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber></AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>baz</Name>
        <Purposes>
          <Purpose>11</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>99</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
      <StockItem>
        <KNumberExists>false</KNumberExists>
        <KNumber></KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber>foo</AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>bar</Name>
        <Purposes>
          <Purpose>2</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>99</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
    </Inventory>
  </Product>
</Products>

$ 

@forikal-uk
Copy link
Collaborator Author

forikal-uk commented May 31, 2018

I am so pleased. :)

@forikal-uk
Copy link
Collaborator Author

forikal-uk commented May 31, 2018

Let's see it act on a Drive folder.

$ pwd
/Users/x/Documents/Projects/XmlAuthoring/gsheet-to-xml
$ php bin/console.php forikal:gsheet-to-xml  https://drive.google.com/drive/folders/12UzI416pEoDzIb5-AeuYJZAF6hhKKdbx?usp=sharing   --credentials=../../../../APIKeys/gsheet-to-xml-e5eaf708560f.json
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Products>
  <Product src-spreadsheet="1ApDJhRGqDS64tVbQygkERJ_CC05KsI_Utq-maeBxklM">
    <Inventory src-sheet="https://drive.google.com/drive/folders/12UzI416pEoDzIb5-AeuYJZAF6hhKKdbx?usp=sharing" src-tab="SomeOtherInventoryTab">
      <StockItem>
        <KNumberExists>true</KNumberExists>
        <KNumber>9999999</KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber></AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>baz</Name>
        <Purposes>
          <Purpose>22</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>11</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
      <StockItem>
        <KNumberExists>false</KNumberExists>
        <KNumber></KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber>bar</AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>bar</Name>
        <Purposes>
          <Purpose>3</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>11</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
    </Inventory>
  </Product>
  <Product src-spreadsheet="1_SnGKyXjHnsdylZw_YYIQ8HuxYQI-hsvxYQpftGMjpM">
    <Inventory src-sheet="https://drive.google.com/drive/folders/12UzI416pEoDzIb5-AeuYJZAF6hhKKdbx?usp=sharing" src-tab="InventoryTab">
      <StockItem>
        <KNumberExists>true</KNumberExists>
        <KNumber>1111111</KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber></AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>baz</Name>
        <Purposes>
          <Purpose>11</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>99</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
      <StockItem>
        <KNumberExists>false</KNumberExists>
        <KNumber></KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber>foo</AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>bar</Name>
        <Purposes>
          <Purpose>2</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>99</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
    </Inventory>
  </Product>
</Products>

$ 

Yes that works.

I note that the Inventory src-sheet attribute is actually defining a Google Folder and not a sheet.

@forikal-uk
Copy link
Collaborator Author

forikal-uk commented Jun 1, 2018

# to do

I would like to set up some Google Files to act as Test Fixtures to test the various Behaviours

Behavior

  • Empty rows are skipped without notice.
  • Files ending with _ (underscore) are ignored (e.g. foo_.xslx, foo_)
  • Tabs ending with _ (underscore) are ignored

Test Fixtures Folder:

Let's make one:

https://drive.google.com/drive/folders/1pgdgRTKQYfMVc1-Kg29FifW-RebwN2Wq?usp=sharing

@forikal-uk
Copy link
Collaborator Author

forikal-uk commented Jun 1, 2018

So that Fixture folder has:

screen shot 2018-06-01 at 01 28 33

$ pwd
/Users/x/Documents/Projects/XmlAuthoring/gsheet-to-xml
$ php bin/console.php forikal:gsheet-to-xml https://drive.google.com/drive/folders/1pgdgRTKQYfMVc1-Kg29FifW-RebwN2Wq?usp=sharing  --credentials=../../../../APIKeys/gsheet-to-xml-e5eaf708560f.json
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Products>
  <Product src-spreadsheet="1hdKksm6Xj6SiL3r8paCzlW2gBMRnm445ZBflUL-591M">
    <Inventory src-sheet="https://drive.google.com/drive/folders/1pgdgRTKQYfMVc1-Kg29FifW-RebwN2Wq?usp=sharing" src-tab="InventoryTab">
      <StockItem>
        <KNumberExists>true</KNumberExists>
        <KNumber>1111111</KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber></AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>baz</Name>
        <Purposes>
          <Purpose>11</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>99</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
      <StockItem>
        <KNumberExists>false</KNumberExists>
        <KNumber></KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber>foo</AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>bar</Name>
        <Purposes>
          <Purpose>2</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>99</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
    </Inventory>
  </Product>
  <Product src-spreadsheet="17BmFwI3yDuHtcGL9uFKkxXHWHD0Mp-TPVp8btG81iQU">
    <Inventory src-sheet="https://drive.google.com/drive/folders/1pgdgRTKQYfMVc1-Kg29FifW-RebwN2Wq?usp=sharing" src-tab="InventoryTab">
      <StockItem>
        <KNumberExists>true</KNumberExists>
        <KNumber>1111111</KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber></AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>baz</Name>
        <Purposes>
          <Purpose>11</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>99</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
      <StockItem>
        <KNumberExists>false</KNumberExists>
        <KNumber></KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber>foo</AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>bar</Name>
        <Purposes>
          <Purpose>2</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>99</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
    </Inventory>
  </Product>
  <Product src-spreadsheet="1Y-rtreSasax15UZ5xQwD48Ou8bVhdQfZOGoq4NxXRLE">
    <Inventory src-sheet="https://drive.google.com/drive/folders/1pgdgRTKQYfMVc1-Kg29FifW-RebwN2Wq?usp=sharing" src-tab="InventoryTab">
      <StockItem>
        <KNumberExists>true</KNumberExists>
        <KNumber>1111111</KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber></AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>baz</Name>
        <Purposes>
          <Purpose>11</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>99</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
      <StockItem>
        <KNumberExists>false</KNumberExists>
        <KNumber></KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber>foo</AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>bar</Name>
        <Purposes>
          <Purpose>2</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>99</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
    </Inventory>
  </Product>
</Products>

$ 

@forikal-uk
Copy link
Collaborator Author

OK it is not so easy to work out which file is which. The src-tab="InventoryTab" attributes are more readable and immediately understandable. But, the sheets are a mystery until one look 'em up manually.

@forikal-uk
Copy link
Collaborator Author

forikal-uk commented Jun 1, 2018

Let's run some unit tests

Tests

Run ./vendor/bin/phpunit to execute test suite

$ ./vendor/bin/phpunit
PHPUnit 7.2-g4e1f80765 by Sebastian Bergmann and contributors.

.....                                                               5 / 5 (100%)

Time: 163 ms, Memory: 4.00MB

OK (5 tests, 23 assertions)
$ 

Nice.

@forikal-uk
Copy link
Collaborator Author

Finally

I like how @zoka123 has added a Resource section at the bottom of the docs. Nice touch.

forikal-uk added a commit to xmlsquad/xml-authoring-library that referenced this issue Jun 1, 2018
... to this page. 

I saved loads of screen grabs during the process and noted location at:
xmlsquad/gsheet-to-xml#6 (comment)
@forikal-uk
Copy link
Collaborator Author

Zoka123 has made some fixes, so let's review this again.

@forikal-uk
Copy link
Collaborator Author

Installation

php bin/gsheet-to-xml.php --help

$ php bin/gsheet-to-xml.php --help
Usage:
  forikal:gsheet-to-xml [options] [--] <drive-url>

Arguments:
  drive-url                        The URL of the Google Drive entity (Google Sheet or Google Drive folder). is-recursive: if the Google Drive entity is a Google Drive folder, this option specifies whether or not to recurse through sub-directories to find sheets.

Options:
  -c, --credentials[=CREDENTIALS]  Path to the Google credentials JSON relative to the current working directory [default: "client_secret.json"]
  -h, --help                       Display this help message
  -q, --quiet                      Do not output any message
  -V, --version                    Display this application version
      --ansi                       Force ANSI output
      --no-ansi                    Disable ANSI output
  -n, --no-interaction             Do not ask any interactive question
  -v|vv|vvv, --verbose             Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
  Fetch and convert Google Drive Folder / Sheets to XML.

@forikal-uk
Copy link
Collaborator Author

I notice that the drive-url description says:

drive-url The URL of the Google Drive entity (Google Sheet or Google Drive folder). is-recursive: if the Google Drive entity is a Google Drive folder, this option specifies whether or not to recurse through sub-directories to find sheets.

So the is-recursive option seems to be mixed in.

I wonder if the is-recursive option/feature is implemented?

@forikal-uk
Copy link
Collaborator Author

forikal-uk commented Jun 2, 2018

I did not notice that bug in my spec the first time I tested the software. Doh!

@forikal-uk
Copy link
Collaborator Author

forikal-uk commented Jun 2, 2018

OK. Let's test those behaviours


Do a call to pick up one file first:

$ pwd
/Users/x/Documents/Projects/XmlAuthoring/gsheet-to-xml


$ php bin/gsheet-to-xml.php forikal:gsheet-to-xml https://docs.google.com/spreadsheets/d/1_SnGKyXjHnsdylZw_YYIQ8HuxYQI-hsvxYQpftGMjpM/edit#gid=311423522 --credentials=../../../../APIKeys/gsheet-to-xml-e5eaf708560f.json

                                                       
  Too many arguments, expected arguments "drive-url".  
                                                       

forikal:gsheet-to-xml [-c|--credentials [CREDENTIALS]] [--] <drive-url>

Try with the options before the argument:

$ php bin/gsheet-to-xml.php forikal:gsheet-to-xml  --credentials=../../../../APIKeys/gsheet-to-xml-e5eaf708560f.json https://docs.google.com/spreadsheets/d/1_SnGKyXjHnsdylZw_YYIQ8HuxYQI-hsvxYQpftGMjpM/edit#gid=311423522

                                                       
  Too many arguments, expected arguments "drive-url".  
                                                       

forikal:gsheet-to-xml [-c|--credentials [CREDENTIALS]] [--] <drive-url>

try with speachmarks

$ php bin/gsheet-to-xml.php forikal:gsheet-to-xml  --credentials="../../../../APIKeys/gsheet-to-xml-e5eaf708560f.json" https://docs.google.com/spreadsheets/d/1_SnGKyXjHnsdylZw_YYIQ8HuxYQI-hsvxYQpftGMjpM/edit#gid=311423522

                                                       
  Too many arguments, expected arguments "drive-url".  
                                                       

forikal:gsheet-to-xml [-c|--credentials [CREDENTIALS]] [--] <drive-url>

@forikal-uk
Copy link
Collaborator Author

## Try without the command name.

$ php bin/gsheet-to-xml.php  --credentials="../../../../APIKeys/gsheet-to-xml-e5eaf708560f.json" https://docs.google.com/spreadsheets/d/1_SnGKyXjHnsdylZw_YYIQ8HuxYQI-hsvxYQpftGMjpM/edit#gid=311423522
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Products>
  <Product>
    <Inventory src-sheet="DocumentationSampleSheet" src-sheet-url="https://docs.google.com/spreadsheets/d/1_SnGKyXjHnsdylZw_YYIQ8HuxYQI-hsvxYQpftGMjpM/edit#gid=311423522" src-tab="InventoryTab">
      <StockItem>
        <KNumberExists>true</KNumberExists>
        <KNumber>1111111</KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber></AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>baz</Name>
        <Purposes>
          <Purpose>11</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>99</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
      <StockItem>
        <KNumberExists>false</KNumberExists>
        <KNumber></KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber>foo</AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>bar</Name>
        <Purposes>
          <Purpose>2</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>99</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
    </Inventory>
  </Product>
</Products>

OK so that worked.

So, I guess, the gsheet-to-xml.php script is hardwired to the gsheet-to-xml command. Which kinda makes sense.

I will need to gain a better understanding of how Symfony commands are designed to be either combined into a suite of commands for a console or 'standalone'.

Either way we need to update the example invocation in the docs.

@forikal-uk
Copy link
Collaborator Author

Check the Xml is written correctly

I have gone through the result of the previous command in the comment above and compared it against the sample source sheet.

At the current time of writing the mapping from gsheet to xml in the above command is perfect.

So the test passes.

@forikal-uk
Copy link
Collaborator Author

 Let's try the command on a Drive folder.

$ php bin/gsheet-to-xml.php  --credentials="../../../../APIKeys/gsheet-to-xml-e5eaf708560f.json" https://drive.google.com/drive/u/0/folders/1pgdgRTKQYfMVc1-Kg29FifW-RebwN2Wq
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Products>
  <Product>
    <Inventory src-sheet="_GoodSheet" src-sheet-url="https://docs.google.com/spreadsheets/d/1hdKksm6Xj6SiL3r8paCzlW2gBMRnm445ZBflUL-591M/" src-tab="InventoryTabA">
      <StockItem>
        <KNumberExists>true</KNumberExists>
        <KNumber>1111111</KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber></AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>baz</Name>
        <Purposes>
          <Purpose>11</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>99</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
      <StockItem>
        <KNumberExists>false</KNumberExists>
        <KNumber></KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber>foo</AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>bar</Name>
        <Purposes>
          <Purpose>2</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>99</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
    </Inventory>
  </Product>
  <Product>
    <Inventory src-sheet="_GoodSheet" src-sheet-url="https://docs.google.com/spreadsheets/d/1hdKksm6Xj6SiL3r8paCzlW2gBMRnm445ZBflUL-591M/" src-tab="InventoryTabB">
      <StockItem>
        <KNumberExists>true</KNumberExists>
        <KNumber>5555555</KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber></AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>baz</Name>
        <Purposes>
          <Purpose>5</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>55</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
      <StockItem>
        <KNumberExists>false</KNumberExists>
        <KNumber></KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber>_GoodSheet &gt; InventoryTabB</AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>bar</Name>
        <Purposes>
          <Purpose>5</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>55</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
    </Inventory>
  </Product>
  <Product>
    <Inventory src-sheet="EmptyRowsSkippedWithoutNotice" src-sheet-url="https://docs.google.com/spreadsheets/d/17BmFwI3yDuHtcGL9uFKkxXHWHD0Mp-TPVp8btG81iQU/" src-tab="InventoryTab">
      <StockItem>
        <KNumberExists>true</KNumberExists>
        <KNumber>1111111</KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber></AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>baz</Name>
        <Purposes>
          <Purpose>11</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>99</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
      <StockItem>
        <KNumberExists>false</KNumberExists>
        <KNumber></KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber>foo</AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>bar</Name>
        <Purposes>
          <Purpose>2</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>99</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
    </Inventory>
  </Product>
  <Product>
    <Inventory src-sheet="TabEndingInUnderscore" src-sheet-url="https://docs.google.com/spreadsheets/d/1Y-rtreSasax15UZ5xQwD48Ou8bVhdQfZOGoq4NxXRLE/" src-tab="InventoryTab">
      <StockItem>
        <KNumberExists>true</KNumberExists>
        <KNumber>1111111</KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber></AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>baz</Name>
        <Purposes>
          <Purpose>11</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>99</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
      <StockItem>
        <KNumberExists>false</KNumberExists>
        <KNumber></KNumber>
        <AdditionalKNumbers></AdditionalKNumbers>
        <AlternativeNumber>foo</AlternativeNumber>
        <InventoryContainerID></InventoryContainerID>
        <Name>bar</Name>
        <Purposes>
          <Purpose>2</Purpose>
        </Purposes>
        <PurposeOther></PurposeOther>
        <InventoryQuantity>99</InventoryQuantity>
        <HandlingStatus></HandlingStatus>
        <SupplierRegistrationNumber></SupplierRegistrationNumber>
      </StockItem>
    </Inventory>
  </Product>
</Products>

@forikal-uk
Copy link
Collaborator Author

Manual test assertions - pass

I have used the, above, result to test the Behaviours listed on the Documentation page:

Behavior

  • Empty rows are skipped without notice.
  • Files ending with _ (underscore) are ignored (e.g. foo_.xslx, foo_)
  • Tabs ending with _ (underscore) are ignored
  • When parsing folders, for every spreadsheet found new <Product> XML element is created with src-spreadsheet attribute
    containing the spreadsheet ID.

forikal-uk added a commit that referenced this issue Jun 3, 2018
I wrote notes as I tested the former version of this commit.

See: #6 (comment)
@forikal-uk
Copy link
Collaborator Author

Run tests again

$ ./vendor/bin/phpunit
PHPUnit 7.3-g2629ff118 by Sebastian Bergmann and contributors.

.....                                                               5 / 5 (100%)

Time: 136 ms, Memory: 4.00MB

OK (5 tests, 23 assertions)

OK Good.

@forikal-uk
Copy link
Collaborator Author

OK. So, I think we have got it working ok whilst meticulously added Issues for all improvements that I'd like to see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant