Skip to content

Commit

Permalink
add different ODS data path support
Browse files Browse the repository at this point in the history
fix app/fake cli
  • Loading branch information
niklongstone committed May 26, 2015
1 parent 74f4cbc commit ba61e3b
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 24 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
@@ -1,3 +1,8 @@
0.6.4 / 2015-05-26
==================
* Add different ODS data path support
* Fix app/fake cli autoload

0.6.3 / 2015-05-23
==================
* Fix new line on string output,
Expand Down
35 changes: 22 additions & 13 deletions README.md
Expand Up @@ -14,26 +14,25 @@ Fakerino is a fake data generator framework fully extensible.

###Main features
Fakerino can:
* Fakes single data (e.g. name, surname, integer, text, ...).
* Fakes complex data (e.g. person: name, surname, hobby, country, ... ).
* Fakes single data (e.g. name, surname, integer, text, ...).
* Fakes data multiple times.
* Fakes a database table row/s automatically.
* Fakes a string or file template automatically (e.g. Hello Mr {{ surname }})
* Fakes a PHP Object.
* Fakes a PHP Object (fills public properties and setters with fake data).
* Supports JSON, array and string output.

For more information about installation, functions, support, contribution, or other,
please read the __[Fakerino wiki](https://github.com/niklongstone/Fakerino/wiki)__.

### Installation
Use [Composer](https://getcomposer.org/download/) to manage the dependencies of your project.
#### Inside your project
####In your project folder run:
```sh
composer require fakerino/fakerino
cd vendor/fakerino/fakerino
build/ods
vendor/fakerino/fakerino/build/ods
```
#### Like a stand-alone project with
#### Like a stand-alone project run:
```sh
composer create-project fakerino/fakerino fakerino
```
Expand All @@ -52,13 +51,23 @@ echo $fakerino->fake(array('nameMale', 'Surname'))->num(3)->toJson(); //[["Simon

//with configuration
$fakerino = Fakerino::create('./conf.php');
print_r($fakerino->fake('fake1')->toArray());
/*
Array(
[0] => Arthur
[1] => Doyle
)
*/
print_r($fakerino->fake('fakeFamily')->toArray());
/*
Array(
[0] => Array
(
[0] => Array
(
[0] => Seth
[1] => Whittaker
)
[1] => Array
(
[0] => Mildred
[1] => King
)
)
)*/
```

#### With Command line
Expand Down
24 changes: 23 additions & 1 deletion app/fake
@@ -1,6 +1,28 @@
#!/usr/bin/env php
<?php
require_once __DIR__.'../../vendor/autoload.php';
/**
* This file is part of the Fakerino package.
*
* (c) Nicola Pietroluongo <niklongstone@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

function includeIfExists($file)
{
if (file_exists($file)) {
return include $file;
}
}
if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) {
fwrite(STDERR,
'You must set up the project dependencies, run the following commands:'.PHP_EOL.
'curl -s http://getcomposer.org/installer | php'.PHP_EOL.
'php composer.phar install'.PHP_EOL
);
exit(1);
}

use Fakerino\Core\Console\FakeConsole;

Expand Down
9 changes: 7 additions & 2 deletions build/ods
@@ -1,13 +1,18 @@
#!/bin/bash
DATAPATH="./data"
if [ -n "$1" ]
then
DATAPATH=$1
fi
echo 'Downloading Open Data Sample'
mkdir -p build
php -r "readfile('https://github.com/niklongstone/open-data-sample/archive/master.zip');" >> build/ods.zip
php -r "readfile('https://github.com/niklongstone/open-data-sample/archive/master.zip');" >> build/ods.zip

echo 'Extracting files'
unzip -qq -o build/ods.zip -d build/

echo 'Configuring ODS'
\cp -rf build/open-data-sample-master/data/ ./data/
\cp -rf build/open-data-sample-master/data/ $DATAPATH

echo 'Removing temporary files'
rm -rf build/open-data-sample-master
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -34,9 +34,10 @@
"config": {
"bin-dir": "bin"
},
"bin": ["app/fake"],
"scripts": {
"post-install-cmd": "build/ods",
"post-update-cmd": "build/ods",
"post-create-project-cmd" : "build/ods"
}
}
}
10 changes: 9 additions & 1 deletion tests/Fakerino/Test/Core/FakeDataFactoryTest.php
Expand Up @@ -29,7 +29,8 @@ public function setUp()
'fake2' => array(
'Name' => array('length' => 30),
'Surname' => null
)
),
'fake3' => array('fake1', 'fake2')
);
FakerinoConf::loadConfiguration($this->conf);
$fakeHandler = new FakeHandler\FakeHandler();
Expand Down Expand Up @@ -111,6 +112,13 @@ public function testFakeToString()
$this->assertInternalType('string', $fakeString);
}

public function testFakeCompplexData()
{
$fakeString = (string) $this->fakeGenerator->fake('fake3');

$this->assertEquals(3, substr_count($fakeString, "\n"));
}

public function testMultipleFakesToString()
{
$num = 3;
Expand Down
6 changes: 0 additions & 6 deletions tests/Fakerino/Test/FakeData/Core/CoreDataTest.php
Expand Up @@ -19,10 +19,4 @@ public function testFileFake()
{
$this->assertInstanceOf('Fakerino\FakeData\FakeDataInterface', new FileFake());
}
/*
public function testGenericString()
{
$this->assertInstanceOf('Fakerino\FakeData\FakeDataInterface', new GenericString());
}
*/
}

0 comments on commit ba61e3b

Please sign in to comment.