3 * @copyright Copyright (C) 2010-2023, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Test\src\Core\Worker\Repository;
24 use Friendica\Core\Worker\Factory;
25 use Friendica\Core\Worker\Repository;
27 use Friendica\Test\FixtureTest;
28 use Psr\Log\NullLogger;
30 class ProcessTest extends FixtureTest
32 public function testStandardProcess()
34 $factory = new Factory\Process(new NullLogger());
35 $repository = new Repository\Process(DI::dba(), new NullLogger(), $factory, []);
37 $entityNew = $repository->create(getmypid(), 'test');
39 self::assertEquals(getmypid(), $entityNew->pid);
40 self::assertEquals('test', $entityNew->command);
41 self::assertLessThanOrEqual(new \DateTime('now', new \DateTimeZone('UTC')), $entityNew->created);
42 self::assertEquals(php_uname('n'), $entityNew->hostname);
45 public function testHostnameEnv()
47 $factory = new Factory\Process(new NullLogger());
48 $repository = new Repository\Process(DI::dba(), new NullLogger(), $factory, [Repository\Process::NODE_ENV => 'test_node']);
50 $entityNew = $repository->create(getmypid(), 'test');
52 self::assertEquals(getmypid(), $entityNew->pid);
53 self::assertEquals('test', $entityNew->command);
54 self::assertLessThanOrEqual(new \DateTime('now', new \DateTimeZone('UTC')), $entityNew->created);
55 self::assertEquals('test_node', $entityNew->hostname);