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

File export extension #14

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Tutorials
* [Mockery](https://github.com/etsy/phpunit-extensions/wiki/Mockery)
* [Multiple Database](https://github.com/etsy/phpunit-extensions/wiki/Multiple-Database)
* [Ticket Listener](https://github.com/etsy/phpunit-extensions/wiki/Ticket-Listener)
* [File Export](https://github.com/etsy/phpunit-extensions/wiki/File-Export)
* [PHPUI Command](https://github.com/etsy/phpunit-extensions/wiki/PHPUI-Command) Experimental!!

Installation
Expand Down
37 changes: 37 additions & 0 deletions Tests/FileExport/ExportTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

use PHPUnit\Extensions\FileExport;

class ExportTest extends FileExport\TestCase {

public function testExportObject () {
$aSampleObject1 = new SampleClass('Joan of Arc', 'Domrémy, France', 'joan@foo.com');
$this->assertExportCompare($aSampleObject1);

$aSampleObject2 = new SampleClass('Hank Hill', '84 Rainey Street, Arlen, TX', 'hank@foo.com');
$this->assertExportCompare($aSampleObject2);
}

public function testExportArray () {
$aSampleArray1 = [ 'this', 'is an array', 'of different types', [ 'many dimensions', 1, 2, 3 ] ];
$this->assertExportCompare($aSampleArray1);

$aSampleArray2 = [ [ 'one', 'two' ], 'and three' ];
$this->assertExportCompare($aSampleArray2);
}
}

class SampleClass {

public function __construct (string $sName, string $sAddress, string $sEmail) {
$this->sName = $sName;
$this->sAddress = $sAddress;
$this->sEmail = $sEmail;
}

public $sName;

public $sAddress;

public $sEmail;
}
12 changes: 12 additions & 0 deletions Tests/FileExport/phpunit_exports/ExportTest/testExportArray.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
array (
0 => 'this',
1 => 'is an array',
2 => 'of different types',
3 =>
array (
0 => 'many dimensions',
1 => 1,
2 => 2,
3 => 3,
),
)
8 changes: 8 additions & 0 deletions Tests/FileExport/phpunit_exports/ExportTest/testExportArray.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
array (
0 =>
array (
0 => 'one',
1 => 'two',
),
1 => 'and three',
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SampleClass::__set_state(array(
'sName' => 'Joan of Arc',
'sAddress' => 'Domrémy, France',
'sEmail' => 'joan@foo.com',
))
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SampleClass::__set_state(array(
'sName' => 'Hank Hill',
'sAddress' => '84 Rainey Street, Arlen, TX',
'sEmail' => 'hank@foo.com',
))
Loading