Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #400 from bessl/master
Browse files Browse the repository at this point in the history
Added Company and Internet Provider for de_AT
  • Loading branch information
fzaninotto committed Aug 26, 2014
2 parents 6c89416 + 0bc3798 commit e49b998
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Faker/Provider/de_AT/Company.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Faker\Provider\de_AT;

class Company extends \Faker\Provider\Company
{
protected static $formats = array(
'{{lastName}} {{companySuffix}}',
'{{lastName}}',
);

protected static $companySuffix = array('AG', 'EWIV', 'Ges.m.b.H.', 'GmbH', 'KEG', 'KG', 'OEG', 'OG', 'OHG', 'SE');
}
45 changes: 45 additions & 0 deletions src/Faker/Provider/de_AT/Internet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Faker\Provider\de_AT;

class Internet extends \Faker\Provider\Internet
{
protected static $freeEmailDomain = array('aon.at', 'chello.at', 'gmail.com', 'gmx.at', 'univie.ac.at');
protected static $tld = array('at', 'co.at', 'com', 'net', 'org');

/**
* Converts German characters (Umlaute) to their ASCII representation
*
* @return string
*/
private static function toAscii($string)
{
$from = array('ä', 'Ä', 'ü', 'Ü', 'ö', 'Ö', 'ß');
$to = array('a', 'A', 'u', 'U', 'o', 'O', 'ss');

return str_replace($from, $to, $string);
}

/**
* @example 'jdoe'
*/
public function userName()
{
$format = static::randomElement(static::$userNameFormats);

return static::toLower(static::toAscii(static::bothify($this->generator->parse($format))));
}

/**
* @example 'faber'
*/
public function domainWord()
{
$company = $this->generator->format('company');
$companyElements = explode(' ', $company);
$company = $companyElements[0];
$company = preg_replace('/\W/u', '', $company);

return static::toLower(static::toAscii($company));
}
}
32 changes: 32 additions & 0 deletions test/Faker/Provider/de_AT/InternetTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Faker\Test\Provider\de_AT;

use Faker\Generator;
use Faker\Provider\de_AT\Person;
use Faker\Provider\de_AT\Internet;
use Faker\Provider\de_AT\Company;

class InternetTest extends \PHPUnit_Framework_TestCase
{

/**
* @var Generator
*/
private $faker;

public function setUp()
{
$faker = new Generator();
$faker->addProvider(new Person($faker));
$faker->addProvider(new Internet($faker));
$faker->addProvider(new Company($faker));
$this->faker = $faker;
}

public function testEmailIsValid()
{
$email = $this->faker->email();
$this->assertNotFalse(filter_var($email, FILTER_VALIDATE_EMAIL));
}
}

0 comments on commit e49b998

Please sign in to comment.