Example #1
0
 public function testGenerate()
 {
     $utilities = $this->getMockBuilder('Faker\\Components\\Engine\\Common\\Utilities')->disableOriginalConstructor()->getMock();
     $generator = $this->getMock('\\PHPStats\\Generator\\GeneratorInterface');
     $locale = $this->getMock('\\Faker\\Locale\\LocaleInterface');
     $database = $this->getProject()->getGeneratorDatabase();
     $generator->expects($this->exactly(2))->method('generate')->with($this->equalTo(0), $this->isType('integer'))->will($this->returnValue(0));
     $utilities->expects($this->exactly(2))->method('generateRandomAlphanumeric')->with($this->isType('string'), $this->isInstanceOf($generator), $this->isInstanceOf($locale))->will($this->onConsecutiveCalls('ddDDD', '1111'));
     $type = new Email($database);
     $type->setGenerator($generator);
     $type->setLocale($locale);
     $type->setUtilities($utilities);
     $type->setOption('format', '{fname}\'{lname}{alpha2}@{alpha1}.{domain}');
     $type->setOption('params', '{"alpha1":"ccCCC","alpha2":"xxxx"}');
     $type->validate();
     $values = array();
     $this->assertEquals('Kristina\'*****@*****.**', $type->generate(1, $values));
 }