public function testDeleteResource() { $expectedObject = ['dummyText' => $this->faker->text(), 'dummyNumber' => $this->faker->randomDigit()]; $transport = $this->getMockBuilder('\\JsonApi\\Transports\\Guzzle')->setMethods(['delete'])->getMock(); $transport->expects($this->once())->method('delete')->willReturn(json_encode($expectedObject)); $client = new Client(); $client->setTransport($transport); $client->deleteResource($this->faker->url()); }
public function testDependency() { $expectedDependency = $this->faker->text(); $di = Di::getInstance(); $dependencyDirectory = sys_get_temp_dir(); $di->setDependenciesDirectory($dependencyDirectory); $tempname = tempnam($dependencyDirectory, ''); $dependency = basename($tempname); $phpFile = $tempname . '.php'; if (is_file($phpFile)) { unlink($phpFile); } file_put_contents($phpFile, "<?php\nreturn '" . addslashes($expectedDependency) . "';\n"); $this->assertEquals($expectedDependency, $di->{$dependency}); unlink($phpFile); unlink($tempname); }
public function testLoad() { $expectedVarValue = $this->faker->text(); $configDirectory = sys_get_temp_dir(); $loader = new Loader(); $loader->setNamespace($configDirectory); $tempname = tempnam($configDirectory, ''); $config = basename($tempname); $phpFile = $tempname . '.php'; if (is_file($phpFile)) { unlink($phpFile); } file_put_contents($phpFile, "<?php\n\$dummy='" . addslashes($expectedVarValue) . "';\n"); $this->assertEquals($expectedVarValue, $loader->loadByKey($loader->getConfigurationKey($config))->dummy); unlink($phpFile); unlink($tempname); }
/** * Generates a node * @param string $nodeId * @param string $startDate * @param string $endDate * @param string $oparg * @return string Node tag with random content */ protected function makeNode($nodeId, $startDate, $endDate, $oparg = '') { $detail = $this->tag('detail', \htmlentities($this->faker->text(150))); $start = strtotime($startDate); $end = strtotime($endDate); // $middleDate = date('Y-m-d H:i:s', $this->faker->numberBetween($start, $end)); $attr = ['pk' => $nodeId, 'label' => 'Primary', 'start' => $startDate, 'end' => $endDate, 'layer' => $this->layers[0]['name'], 'oparg' => $oparg]; $first = $this->tag('node', $detail, $attr); // // use the second layer // $attrTwo = array_merge($attr, [ // 'pk' => "{$nodeId}-s", // 'label' => ' ', // We'll empty this // 'start' => $middleDate, // 'end' => $endDate, // 'layer' => $this->layers[1]['name'], // ]); // $second = $this->tag('node', $this->tag('detail', ''), $attrTwo); return "\n\t\t{$first}"; }
public function testGetLoaderException() { $this->setExpectedException('\\ConfigurationFactory\\Exception', 'loader not setted'); $factory = new ConfigurationFactory(); $factory->get($this->faker->text()); }