Example #1
1
 public function test_it_can_activate_a_language()
 {
     $LanguageManager = new LanguagesManager(new \DvsLanguage());
     $LanguageManager->modifyActiveFlag($id = 31, $isActive = true);
     // the active flag should be true now...
     assertEquals(true, \DvsLanguage::find(31)->active);
 }
 public function testCanVulgarizeStrings()
 {
     $monkeyFighter = new MonkeyFighter('F**k MotherF*!ker S#!t P*$$! P**s Muthaf#$!ing C**KSUCKER NI**** N***A N*$@ah T**s T$$TYf**! A-- B--CH D*** F@G F@***t');
     $dirty = $monkeyFighter->getVulgarized();
     assertEquals('F**k M**********r Shit Pussy Piss Muthafucking C********R NIGGER N***A Niggah T**s TITTYfuck Ass BITCH Damn F*G F****t', $dirty);
     $monkeyFighter = new MonkeyFighter('Mother****** with the Hat');
     $dirty = $monkeyFighter->getVulgarized();
     assertEquals('M**********r with the Hat', $dirty);
     $monkeyFighter = new MonkeyFighter('Mr. Muthaf**kin Exquire');
     $dirty = $monkeyFighter->getVulgarized();
     assertEquals('Mr. Muthafuckin Exquire', $dirty);
     $monkeyFighter = new MonkeyFighter('F*CK F*ck f*ck');
     $dirty = $monkeyFighter->getVulgarized();
     assertEquals('F**K F**k f**k', $dirty);
     $monkeyFighter = new MonkeyFighter('Starf**ker Startf**ker');
     $dirty = $monkeyFighter->getVulgarized();
     assertEquals('Starfucker Startfucker', $dirty);
     $monkeyFighter = new MonkeyFighter('Hot Sh*t All Stars');
     $dirty = $monkeyFighter->getVulgarized();
     assertEquals('Hot Shit All Stars', $dirty);
     $monkeyFighter = new MonkeyFighter('The F***ing Champs');
     $dirty = $monkeyFighter->getVulgarized();
     assertEquals('The F*****g Champs', $dirty);
     $monkeyFighter = new MonkeyFighter('Goblin C*ck');
     $dirty = $monkeyFighter->getVulgarized();
     assertEquals('Goblin C**k', $dirty);
     $monkeyFighter = new MonkeyFighter('F*cktard');
     $dirty = $monkeyFighter->getVulgarized();
     assertEquals('Fucktard', $dirty);
     $monkeyFighter = new MonkeyFighter('Dane Cook Elizabeth Cook DC 101 Chili Cook-Off Bethune Cookman Wildcats Baseball');
     $dirty = $monkeyFighter->getVulgarized();
     assertEquals('Dane Cook Elizabeth Cook DC 101 Chili Cook-Off Bethune Cookman Wildcats Baseball', $dirty);
 }
Example #3
0
 public function test_it_can_give_me_primary_language_id()
 {
     $Config = m::mock('Illuminate\\Config\\Repository');
     $Config->shouldReceive('get')->times(1)->andReturn(45);
     $LanguageDetector = new LanguageDetector(new LocaleDetector($this->Framework), new \DvsLanguage(), $Config);
     assertEquals(45, $LanguageDetector->primaryLanguageId());
 }
 /**
  * @test
  * @profile fork
  */
 public function testParse()
 {
     split_time('Reset');
     $annotations = Annotations::get('Components\\Type_Test_Unit_Case_Annotations_Entity');
     split_time('Invoke Annotations::get(Components\\Type_Test_Unit_Case_Annotations_Entity)');
     $annotations = Annotations::get('Components\\Type_Test_Unit_Case_Annotations_Entity');
     split_time('Invoke Annotations::get(Components\\Type_Test_Unit_Case_Annotations_Entity)');
     assertTrue($annotations->hasTypeAnnotation(Annotation_Name::NAME));
     split_time('Invoke Annotations$hasMethodAnnotation(name)');
     assertTrue($annotations->hasTypeAnnotation(Annotation_Name::NAME));
     split_time('Invoke Annotations$hasMethodAnnotation(name)');
     assertTrue($annotations->hasTypeAnnotation('package'));
     split_time('Invoke Annotations$hasMethodAnnotation(package)');
     assertFalse($annotations->hasTypeAnnotation('version'));
     split_time('Invoke Annotations$hasMethodAnnotation(version)');
     assertTrue($annotations->hasMethodAnnotation('poke', Annotation_Name::NAME));
     split_time('Invoke Annotations$hasMethodAnnotation(poke)');
     assertTrue($annotations->hasMethodAnnotation('poke', Annotation_Name::NAME));
     split_time('Invoke Annotations$hasMethodAnnotation(poke)');
     $pokeName = $annotations->getMethodAnnotation('poke', Annotation_Name::NAME);
     split_time('Invoke Annotations$getMethodAnnotation(poke)');
     $pokeName = $annotations->getMethodAnnotation('poke', Annotation_Name::NAME);
     split_time('Invoke Annotations$getMethodAnnotation(poke)');
     $annotations = Annotations::get(__CLASS__);
     split_time('Invoke Annotations::get(' . __CLASS__ . ')');
     $annotations = Annotations::get(__CLASS__);
     split_time('Invoke Annotations::get(' . __CLASS__ . ')');
     assertEquals('poke', $pokeName->value);
 }
 /**
  * @covers Mobileka\ScopeApplicator\Configurator::prepareScopes
  * @test
  */
 public function prepares_scope_configuration()
 {
     $configurator = $this->getInstance(null, ['scope', 'aliasedScope' => ['alias' => 'scopeAlias', 'keys' => ['firstKey', 'secondKey'], 'type' => 'int'], 'booleanScope' => ['type' => 'boolean']]);
     $expect = ['scope' => ['alias' => 'scope'], 'aliasedScope' => ['alias' => 'scopeAlias', 'keys' => ['firstKey', 'secondKey'], 'type' => 'int'], 'booleanScope' => ['alias' => 'booleanScope', 'type' => 'boolean']];
     $result = $configurator->prepareScopes();
     assertEquals($expect, $result);
 }
Example #6
0
 public function test_it_removes_instance()
 {
     $previous = $this->CollectionInstance->count();
     $this->CollectionsManager->removeInstance(1);
     $current = $this->CollectionInstance->count();
     assertEquals($previous - 1, $current);
 }
Example #7
0
 public function testName()
 {
     $field = new StringField('hello');
     assertEquals($field->name(), 'hello');
     assertEquals($field->name('what'), $field);
     assertEquals($field->name(), 'what');
 }
Example #8
0
 public function test_it_updates_page_version()
 {
     $event = $this->PageVersionSource->updatePageVersion(9999, '2015-01-01 00:00:00', '2015-01-01 23:59:59', $published = true);
     assertEquals(9999, $event->id);
     assertEquals('2015-01-01 00:00:00', $event->start);
     assertEquals(true, $event->published);
 }
Example #9
0
 public function testEmptyUrlGenerator()
 {
     $configurations = ['default' => 'AwsS3', 'url' => 'https://s3.amazonaws.com', 'threshold' => 10, 'providers' => ['aws' => ['s3' => ['region' => 'us-standard', 'version' => 'latest', 'buckets' => ['' => '*'], 'acl' => 'public-read', 'cloudfront' => ['use' => false, 'cdn_url' => null], 'metadata' => [], 'expires' => gmdate('D, d M Y H:i:s T', strtotime('+5 years')), 'cache-control' => 'max-age=2628000', 'version' => null, 'http' => null]]]];
     $this->p_awsS3Provider->init($configurations);
     $result = $this->p_awsS3Provider->urlGenerator($this->path);
     assertEquals($this->path_url, $result);
 }
Example #10
0
 public function test_it_can_replace_live_span()
 {
     $original = '@if(DeviseUser::checkRule(\'@livespan(#target-form-id,default value)\')) @endif <h3>\\@livespan(selector, value)</h3> @livespan(selector) @livespan() @livespan[selector, durka]';
     $LiveSpan = new LiveSpan(new \Devise\Support\Str());
     $replaced = $LiveSpan->replace($original);
     assertEquals('@if(DeviseUser::checkRule(\'<span data-livespan="#target-form-id">default value</span>\')) @endif <h3>@livespan(selector, value)</h3> <span data-livespan="selector"></span> <span data-livespan=""></span> <span data-livespan="selector">durka</span>', $replaced);
 }
Example #11
0
 public function test_it_cannot_store_permission()
 {
     $input = $this->buildInput(['permission_name' => 'blah blah blah']);
     $result = $this->PermissionsManager->storePermission($input);
     assertInternalType('bool', $result);
     assertEquals(false, $result);
 }
 public function test_it_can_execute_variable_store()
 {
     $this->TemplatesManager->shouldReceive('storeNewVariable')->andReturnSelf();
     $this->Framework->Redirect->shouldReceive('route')->andReturnSelf()->shouldReceive('with')->andReturn('Variable successfully created');
     $result = $this->TemplatesResponseHandler->executeVariableStore('foo.template.path', ['foo' => 'input']);
     assertEquals('Variable successfully created', $result);
 }
 /**
  * @Then /^I should have a "([^"]*)" field as a "([^"]*)" type, has a "([^"]*)" widget, (not required|required), and allows (\d+|(?i)unlimited) value[s]?[.]?$/
  */
 public function iShouldHaveAFieldAsTypeHasAWidgetRequiredAndAllowsValue($name, $type, $widget, $required, $cardinality)
 {
     if (strcasecmp($cardinality, 'unlimited') == 0) {
         $cardinality = '-1';
     }
     $fields = field_info_instances("node", $this->contentType->type);
     $wantedField = NULL;
     foreach ($fields as $field) {
         if ($field['label'] == $name) {
             $wantedField = $field;
         }
     }
     assertNotEmpty($wantedField, "Field with the label {$name} doesn't exist");
     $fieldInfo = field_info_field($wantedField['field_name']);
     $widgetInfo = field_info_widget_types();
     $fieldTypeInfo = field_info_field_types();
     $wantedField['widget']['info'] = $widgetInfo[$wantedField['widget']['type']];
     $wantedField['type'] = $fieldTypeInfo[$fieldInfo['type']];
     assertEquals($type, $wantedField['type']['label'], "{$name} doesn't have the type {$type}. Instead it has " . $wantedField['type']['label'] . '.');
     assertEquals($widget, $wantedField['widget']['info']['label'], "{$name} doesn't have the widget type {$widget}. Instead it has " . $wantedField['widget']['info']['label'] . '.');
     $fieldRequired = $wantedField['required'] ? 'required' : 'not required';
     assertEquals($required, $fieldRequired, "{$name} is marked '{$fieldRequired}'. It should be '{$required}'.");
     assertEquals($cardinality, $fieldInfo['cardinality'], "{$name} allows " . $fieldInfo['cardinality'] . " values. It should only allow {$cardinality} values.");
     $this->fieldList[] = $wantedField['field_name'];
 }
 public function testItMapsTheConfigArrayToInflectorDefinitions()
 {
     $interface = 'example_interface';
     $methods = ['method1' => ['arg1', 'arg2']];
     $subject = new InflectorConfig([$interface => $methods]);
     assertEquals([new InflectorDefinition($interface, $methods)], iterator_to_array($subject));
 }
Example #15
0
 /**
  * Integration Test.
  */
 public function testPushCommand()
 {
     $configuration_file = ['bypass' => false, 'default' => 'AwsS3', 'url' => 'https://s3.amazonaws.com', 'threshold' => 10, 'providers' => ['aws' => ['s3' => ['region' => 'us-standard', 'version' => 'latest', 'buckets' => ['my-bucket-name' => '*'], 'acl' => 'public-read', 'cloudfront' => ['use' => false, 'cdn_url' => ''], 'metadata' => [], 'expires' => gmdate('D, d M Y H:i:s T', strtotime('+5 years')), 'cache-control' => 'max-age=2628000', 'version' => '']]], 'include' => ['directories' => [__DIR__], 'extensions' => [], 'patterns' => []], 'exclude' => ['directories' => [], 'files' => [], 'extensions' => [], 'patterns' => [], 'hidden' => true]];
     $m_consol = M::mock('Symfony\\Component\\Console\\Output\\ConsoleOutput');
     $m_consol->shouldReceive('writeln')->atLeast(1);
     $finder = new \Vinelab\Cdn\Finder($m_consol);
     $asset = new \Vinelab\Cdn\Asset();
     $provider_factory = new \Vinelab\Cdn\ProviderFactory();
     $m_config = M::mock('Illuminate\\Config\\Repository');
     $m_config->shouldReceive('get')->with('cdn')->once()->andReturn($configuration_file);
     $helper = new \Vinelab\Cdn\CdnHelper($m_config);
     $m_console = M::mock('Symfony\\Component\\Console\\Output\\ConsoleOutput');
     $m_console->shouldReceive('writeln')->atLeast(2);
     $m_validator = M::mock('Vinelab\\Cdn\\Validators\\Contracts\\ProviderValidatorInterface');
     $m_validator->shouldReceive('validate');
     $m_helper = M::mock('Vinelab\\Cdn\\CdnHelper');
     $m_spl_file = M::mock('Symfony\\Component\\Finder\\SplFileInfo');
     $m_spl_file->shouldReceive('getPathname')->andReturn('vinelab/cdn/tests/Vinelab/Cdn/AwsS3ProviderTest.php');
     $m_spl_file->shouldReceive('getRealPath')->andReturn(__DIR__ . '/AwsS3ProviderTest.php');
     // partial mock
     $p_aws_s3_provider = M::mock('\\Vinelab\\Cdn\\Providers\\AwsS3Provider[connect]', array($m_console, $m_validator, $m_helper));
     $m_s3 = M::mock('Aws\\S3\\S3Client')->shouldIgnoreMissing();
     $m_s3->shouldReceive('factory')->andReturn('Aws\\S3\\S3Client');
     $m_command = M::mock('Aws\\Command');
     $m_s3->shouldReceive('getCommand')->andReturn($m_command);
     $m_s3->shouldReceive('execute');
     $p_aws_s3_provider->setS3Client($m_s3);
     $p_aws_s3_provider->shouldReceive('connect')->andReturn(true);
     \Illuminate\Support\Facades\App::shouldReceive('make')->once()->andReturn($p_aws_s3_provider);
     $cdn = new \Vinelab\Cdn\Cdn($finder, $asset, $provider_factory, $helper);
     $result = $cdn->push();
     assertEquals($result, true);
 }
 /**
  * @Then /^I should get the following products after apply the following updater to it:$/
  *
  * @param TableNode $updates
  *
  * @throws \Exception
  */
 public function iShouldGetTheFollowingProductsAfterApplyTheFollowingUpdaterToIt(TableNode $updates)
 {
     $application = $this->getApplicationsForUpdaterProduct();
     $updateCommand = $application->find('pim:product:update');
     $updateCommand->setContainer($this->getMainContext()->getContainer());
     $updateCommandTester = new CommandTester($updateCommand);
     $getCommand = $application->find('pim:product:get');
     $getCommand->setContainer($this->getMainContext()->getContainer());
     $getCommandTester = new CommandTester($getCommand);
     foreach ($updates->getHash() as $update) {
         $username = isset($update['username']) ? $update['username'] : null;
         $updateCommandTester->execute(['command' => $updateCommand->getName(), 'identifier' => $update['product'], 'json_updates' => $update['actions'], 'username' => $username]);
         $expected = json_decode($update['result'], true);
         if (isset($expected['product'])) {
             $getCommandTester->execute(['command' => $getCommand->getName(), 'identifier' => $expected['product']]);
             unset($expected['product']);
         } else {
             $getCommandTester->execute(['command' => $getCommand->getName(), 'identifier' => $update['product']]);
         }
         $actual = json_decode($getCommandTester->getDisplay(), true);
         if (null === $actual) {
             throw new \Exception(sprintf('An error occured during the execution of the update command : %s', $getCommandTester->getDisplay()));
         }
         if (null === $expected) {
             throw new \Exception(sprintf('Looks like the expected result is not valid json : %s', $update['result']));
         }
         $diff = $this->arrayIntersect($actual, $expected);
         assertEquals($expected, $diff);
     }
 }
Example #17
0
 public function test_ensure_interpret_doesnt_make_deleted_at()
 {
     unset($this->input['deleted_at']);
     $this->ScaffoldingManager->interpretInputData($this->input);
     assertEquals(count($this->input['fields']), 4);
     assertNotEquals($this->input['fields'][2]['name'], 'deleted_at');
 }
Example #18
0
 /**
  * @Then /^у меня должна быть подписка на все активные ивенты$/
  */
 public function iMustHaveTicketForAllEvents()
 {
     $activeEvents = $this->kernel->getContainer()->get('doctrine')->getManager()->getRepository('StfalconEventBundle:Event')->findBy(array('active' => true));
     $user = $this->kernel->getContainer()->get('fos_user.user_manager')->findUserByEmail('*****@*****.**');
     $tickets = $this->kernel->getContainer()->get('doctrine')->getManager()->getRepository('StfalconEventBundle:Ticket')->findBy(array('user' => $user->getId()));
     assertEquals(count($tickets), count($activeEvents));
 }
Example #19
0
 public function test_it_can_get_rule_param_map()
 {
     $rules = $this->PermissionsRepository->availableRulesList();
     $results = $this->PermissionsRepository->getRuleParamMap($rules);
     assertInternalType('array', $results);
     assertEquals(1, $results['hasEmail']);
 }
Example #20
0
 public function testPathIsCallingUrlGenerator()
 {
     $this->provider->shouldReceive('urlGenerator')->once()->andReturn($this->asset_url);
     $result = $this->facade->asset($this->path_path);
     // assert is calling the url generator
     assertEquals($result, $this->asset_url);
 }
 public function testReadsAPHPConfigFile()
 {
     $config = ['key' => 'value'];
     $code = '<?php return ' . var_export($config, true) . ';';
     $this->createTestFile('config.php', $code);
     assertEquals($config, $this->reader->read($this->getTestPath('config.php')));
 }
 /**
  * @test
  * @profile
  */
 public function testDispatch()
 {
     split_time('reset');
     Rest_Test_Unit_Case_Resource_Foo::serve('resource/foo');
     split_time('Invoke Rest_Test_Unit_Case_Resource_Foo::serve(resource/foo)');
     Http_Scriptlet_Context::push(new Http_Scriptlet_Context(Environment::uriComponents()));
     split_time('Initialize Components\\Http_Scriptlet_Context');
     $uri = Uri::valueOf(Environment::uriComponents('rest', 'resource', 'foo', 'poke', '1234.json'));
     split_time("Invoke Uri::valueOf({$uri})");
     ob_start();
     split_time('reset');
     Http_Scriptlet_Context::current()->dispatch($uri, Http_Scriptlet_Request::METHOD_GET);
     split_time("Invoke Components\\Http_Scriptlet_Context\$dispatch([{$uri}], GET)");
     $result = ob_get_clean();
     assertEquals(json_encode(true), $result);
     split_time('reset');
     $uri = Uri::valueOf(Environment::uriComponents('rest', 'resource', 'foo', 'poke', '1234.json'));
     $uri->setQueryParam('log', 'false');
     split_time("Invoke Uri::valueOf({$uri})");
     ob_start();
     split_time('reset');
     Http_Scriptlet_Context::current()->dispatch($uri, Http_Scriptlet_Request::METHOD_GET);
     split_time("Invoke Components\\Http_Scriptlet_Context\$dispatch([{$uri}], GET)");
     $result = ob_get_clean();
     assertEquals(json_encode(false), $result);
 }
Example #23
0
 public function test_it_cant_create_new_page()
 {
     $this->PageVersionManager->shouldReceive('createDefaultPageVersion')->times(0);
     $page = $this->ApiPagesManager->createNewPage(['title' => 'Some page title', 'slug' => '/some-page-title', 'http_verb' => 'get']);
     assertFalse($page);
     assertEquals(count($this->ApiPagesManager->errors), 1);
 }
Example #24
0
 public function test_it_gets_a_filter()
 {
     $Manager = m::mock('Devise\\Support\\Sortable\\Manager');
     $Framework = new \Devise\Support\Framework();
     $Sort = new Sort($Manager, $Framework);
     assertEquals('<input type="text" name="dvs-filters[filtername]" data-dvs-replacement="[some-selector]" value="" >', $Sort->filter('filtername', '[some-selector]'));
 }
Example #25
0
 public function testExcludedHidden()
 {
     $bol = true;
     $this->asset->init(['exclude' => ['hidden' => $bol]]);
     $result = $this->asset->getExcludeHidden();
     assertEquals($result, $bol);
 }
Example #26
0
 public function test_it_copies_page()
 {
     $this->RoutesGenerator->shouldReceive('cacheRoutes')->once();
     $this->PageVersionManager->shouldReceive('copyPageVersionToAnotherPage')->times(1);
     $newPage = $this->PageManager->copyPage(1, ['title' => 'Some page title', 'slug' => '/some-page-title', 'http_verb' => 'get', 'view' => 'some.view.path']);
     assertNotEquals(1, $newPage->id);
     assertEquals('Some page title', $newPage->title);
 }
Example #27
0
 public function test_it_gets_link()
 {
     $Framework = new \Devise\Support\Framework();
     $cookie = [];
     $Link = new Link($Framework);
     $output = $Link->getLink($cookie);
     assertEquals('<a href="http://localhost?dir=asc" class="page-sort"></a> ', $output);
 }
 function filterDataWithOneSubgroup(){
     //The service got to return a list with values classifyied per group. 
     //this list must have one data per line, indicating the year, origin, destiny, 
     //variety and type, in addition to value. 
     
     $service = new DataFilterService();
     assertEquals($value, $expected);
 }
 /**
  * @param TableNode $table
  *
  * @Given /^(?:the )?response should contain the following data:$/
  */
 public function theResponseShouldContainTheFollowingData(TableNode $table)
 {
     $response = json_decode($this->getBrowser()->getLastResponse()->getContent(), true);
     foreach ($table->getHash() as $data) {
         assertArrayHasKey($data['key'], $response);
         assertEquals($response[$data['key']], $data['value']);
     }
 }
Example #30
-1
function parseNounGroup($modelType, $inflections, $expectedModels)
{
    $numModels = 0;
    $buf = captureTr();
    while (count($buf)) {
        $cells = $buf;
        // We might need to read a second row sometimes. The second row does
        // not contain the model number, so the columns are shifted by 1.
        $buf = captureTr();
        if (count($buf) && !preg_match('/\\d+\\./', $buf[0])) {
            assert(count($buf) == 2);
            $cells[1] .= $buf[0];
            $cells[5] .= $buf[1];
            $buf = captureTr();
        }
        assert(preg_match('/\\d+\\./', $cells[0]));
        assert(count($cells) == 9 || count($cells) == 10);
        $descr = count($cells) == 10 ? $cells[9] : '';
        $modelNumber = substr($cells[0], 0, strlen($cells[0]) - 1);
        $forms = array_splice($cells, 1, 8);
        dprintArray($forms, $modelNumber);
        saveCommonModel($modelType, $modelNumber, $forms, $descr, $inflections);
        $numModels++;
    }
    assertEquals($expectedModels, $numModels);
}