xmlsquad / gsheet-to-xml

Given the url of a Google Sheet, this Symfony Console command fetches the Google Sheet and outputs it in the form of Xml.
Apache License 2.0
3 stars 1 forks source link

Test the initial version of the app #6

Closed forikal-uk closed 6 years ago

forikal-uk commented 6 years ago

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 commented 6 years ago

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

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 commented 6 years ago

Sort out the G API connections

Google API Setup

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

Done.

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.

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

I am so pleased. :)

forikal-uk commented 6 years ago

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 commented 6 years ago

 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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

Let's look at the tests:

forikal-uk commented 6 years ago

Finally

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

forikal-uk commented 6 years ago

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

forikal-uk commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

forikal-uk commented 6 years ago

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 commented 6 years ago

 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 commented 6 years ago

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 commented 6 years ago

 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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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