1616use PHPUnit \Framework \SkippedTest ;
1717use RuntimeException ;
1818use stdClass ;
19+ use Support \Data \DummyClass ;
1920
2021final class AssertsTest extends TestCase
2122{
@@ -45,16 +46,17 @@ public function testCodeceptionAsserts(): void
4546
4647 public function testPHPUnitAsserts (): void
4748 {
49+ $ dir = codecept_data_dir ();
4850 $ this ->module ->assertArrayHasKey ('one ' , ['one ' => 1 , 'two ' => 2 ]);
4951 $ this ->module ->assertArrayNotHasKey ('three ' , ['one ' => 1 , 'two ' => 2 ]);
50- $ this ->module ->assertClassHasAttribute ('foo ' , \ Support \ Data \ DummyClass::class);
51- $ this ->module ->assertClassHasStaticAttribute ('staticFoo ' , \ Support \ Data \ DummyClass::class);
52- $ this ->module ->assertClassNotHasAttribute ('bar ' , \ Support \ Data \ DummyClass::class);
53- $ this ->module ->assertClassNotHasStaticAttribute ('staticBar ' , \ Support \ Data \ DummyClass::class);
52+ $ this ->module ->assertClassHasAttribute ('foo ' , DummyClass::class);
53+ $ this ->module ->assertClassHasStaticAttribute ('staticFoo ' , DummyClass::class);
54+ $ this ->module ->assertClassNotHasAttribute ('bar ' , DummyClass::class);
55+ $ this ->module ->assertClassNotHasStaticAttribute ('staticBar ' , DummyClass::class);
5456 $ this ->module ->assertContains (1 , [1 , 2 ]);
5557 $ this ->module ->assertContainsEquals (2 , [1 , 2 ]);
56- $ this ->module ->assertContainsOnly (\ Support \ Data \ DummyClass::class, [new \ Support \ Data \ DummyClass (), new \ Support \ Data \ DummyClass ()]);
57- $ this ->module ->assertContainsOnlyInstancesOf (\ Support \ Data \ DummyClass::class, [new \ Support \ Data \ DummyClass (), new \ Support \ Data \ DummyClass ()]);
58+ $ this ->module ->assertContainsOnly (DummyClass::class, [new DummyClass (), new DummyClass ()]);
59+ $ this ->module ->assertContainsOnlyInstancesOf (DummyClass::class, [new DummyClass (), new DummyClass ()]);
5860 $ this ->module ->assertCount (3 , [1 , 2 , 3 ]);
5961 $ this ->module ->assertDirectoryDoesNotExist (__DIR__ . 'notExist ' );
6062 $ this ->module ->assertDirectoryExists (__DIR__ );
@@ -71,17 +73,17 @@ public function testPHPUnitAsserts(): void
7173 $ this ->module ->assertEqualsWithDelta (1.0 , 1.01 , 0.1 );
7274 $ this ->module ->assertFalse (false );
7375 $ this ->module ->assertFileDoesNotExist (__FILE__ . '.notExist ' );
74- $ this ->module ->assertFileEquals (codecept_data_dir () . '/data1.txt ' , codecept_data_dir () . '/data1.txt ' );
75- $ this ->module ->assertFileEqualsCanonicalizing (codecept_data_dir () . '/data1.txt ' , codecept_data_dir () . '/data1.txt ' );
76- $ this ->module ->assertFileEqualsIgnoringCase (codecept_data_dir () . '/data1.txt ' , codecept_data_dir () . '/data2.txt ' );
76+ $ this ->module ->assertFileEquals ($ dir . '/data1.txt ' , $ dir . '/data1.txt ' );
77+ $ this ->module ->assertFileEqualsCanonicalizing ($ dir . '/data1.txt ' , $ dir . '/data1.txt ' );
78+ $ this ->module ->assertFileEqualsIgnoringCase ($ dir . '/data1.txt ' , $ dir . '/data2.txt ' );
7779 $ this ->module ->assertFileExists (__FILE__ );
7880 // assertFileIsNotReadable
7981 // assertFileIsNotWritable
8082 $ this ->module ->assertFileIsReadable (__FILE__ );
8183 $ this ->module ->assertFileIsWritable (__FILE__ );
82- $ this ->module ->assertFileNotEquals (codecept_data_dir () . '/data1.json ' , codecept_data_dir () . '/data1.txt ' );
83- $ this ->module ->assertFileNotEqualsCanonicalizing (codecept_data_dir () . '/data1.txt ' , codecept_data_dir () . '/data3.txt ' );
84- $ this ->module ->assertFileNotEqualsIgnoringCase (codecept_data_dir () . '/data1.txt ' , codecept_data_dir () . '/data3.txt ' );
84+ $ this ->module ->assertFileNotEquals ($ dir . '/data1.json ' , $ dir . '/data1.txt ' );
85+ $ this ->module ->assertFileNotEqualsCanonicalizing ($ dir . '/data1.txt ' , $ dir . '/data3.txt ' );
86+ $ this ->module ->assertFileNotEqualsIgnoringCase ($ dir . '/data1.txt ' , $ dir . '/data3.txt ' );
8587 $ this ->module ->assertFinite (2 );
8688 $ this ->module ->assertGreaterThan (5 , 6 );
8789 $ this ->module ->assertGreaterThanOrEqual (5 , 5 );
@@ -123,18 +125,18 @@ public function testPHPUnitAsserts(): void
123125 $ this ->module ->assertIsString ('test ' );
124126 $ this ->module ->assertIsWritable (__FILE__ );
125127 $ this ->module ->assertJson ('[] ' );
126- $ this ->module ->assertJsonFileEqualsJsonFile (codecept_data_dir () . '/data1.json ' , codecept_data_dir () . '/data1.json ' );
127- $ this ->module ->assertJsonFileNotEqualsJsonFile (codecept_data_dir () . '/data1.json ' , codecept_data_dir () . '/data2.json ' );
128- $ this ->module ->assertJsonStringEqualsJsonFile (codecept_data_dir () . '/data1.json ' , '["foo", "bar"] ' );
128+ $ this ->module ->assertJsonFileEqualsJsonFile ($ dir . '/data1.json ' , $ dir . '/data1.json ' );
129+ $ this ->module ->assertJsonFileNotEqualsJsonFile ($ dir . '/data1.json ' , $ dir . '/data2.json ' );
130+ $ this ->module ->assertJsonStringEqualsJsonFile ($ dir . '/data1.json ' , '["foo", "bar"] ' );
129131 $ this ->module ->assertJsonStringEqualsJsonString ('["foo", "bar"] ' , '[ "foo" , "bar" ] ' );
130- $ this ->module ->assertJsonStringNotEqualsJsonFile (codecept_data_dir () . '/data1.json ' , '["bar", "foo"] ' );
132+ $ this ->module ->assertJsonStringNotEqualsJsonFile ($ dir . '/data1.json ' , '["bar", "foo"] ' );
131133 $ this ->module ->assertJsonStringNotEqualsJsonString ('["foo", "bar"] ' , '["bar", "foo"] ' );
132134 $ this ->module ->assertLessThan (4 , 3 );
133135 $ this ->module ->assertLessThanOrEqual (3 , 3 );
134136 $ this ->module ->assertMatchesRegularExpression ('/^[\d]$/ ' , '1 ' );
135137 $ this ->module ->assertNan (sqrt (-1 ));
136138 $ this ->module ->assertNotContains ('three ' , ['one ' , 'two ' ]);
137- $ this ->module ->assertNotContainsOnly (\ Support \ Data \ DummyClass::class, [new \ Support \ Data \ DummyClass (), new Exception ()]);
139+ $ this ->module ->assertNotContainsOnly (DummyClass::class, [new DummyClass (), new Exception ()]);
138140 $ this ->module ->assertNotCount (1 , ['one ' , 'two ' ]);
139141 $ this ->module ->assertNotEmpty ([1 ]);
140142 $ this ->module ->assertNotEquals (true , false );
@@ -154,35 +156,35 @@ public function testPHPUnitAsserts(): void
154156 $ this ->module ->assertNotTrue (null );
155157 $ this ->module ->assertNotTrue ('foo ' );
156158 $ this ->module ->assertNull (null );
157- $ this ->module ->assertObjectHasAttribute ('foo ' , new \ Support \ Data \ DummyClass ());
158- $ this ->module ->assertObjectNotHasAttribute ('bar ' , new \ Support \ Data \ DummyClass ());
159+ $ this ->module ->assertObjectHasAttribute ('foo ' , new DummyClass ());
160+ $ this ->module ->assertObjectNotHasAttribute ('bar ' , new DummyClass ());
159161 $ this ->module ->assertSame (1 , 1 );
160162 $ this ->module ->assertSameSize ([1 , 2 , 3 ], [1 , 2 , 3 ]);
161163 $ this ->module ->assertStringContainsString ('bar ' , 'foobar ' );
162164 $ this ->module ->assertStringContainsStringIgnoringCase ('bar ' , 'FooBar ' );
163165 $ this ->module ->assertStringEndsNotWith ('fo ' , 'foo ' );
164166 $ this ->module ->assertStringEndsWith ('oo ' , 'foo ' );
165- $ this ->module ->assertStringEqualsFile (codecept_data_dir () . '/data1.txt ' , 'foo bar foo ' );
166- $ this ->module ->assertStringEqualsFileCanonicalizing (codecept_data_dir () . '/data1.txt ' , 'foo bar foo ' );
167- $ this ->module ->assertStringEqualsFileIgnoringCase (codecept_data_dir () . '/data1.txt ' , 'foo bAr foo ' );
167+ $ this ->module ->assertStringEqualsFile ($ dir . '/data1.txt ' , 'foo bar foo ' );
168+ $ this ->module ->assertStringEqualsFileCanonicalizing ($ dir . '/data1.txt ' , 'foo bar foo ' );
169+ $ this ->module ->assertStringEqualsFileIgnoringCase ($ dir . '/data1.txt ' , 'foo bAr foo ' );
168170 $ this ->module ->assertStringMatchesFormat ('*%s* ' , '*** ' );
169- $ this ->module ->assertStringMatchesFormatFile (codecept_data_dir () . '/expectedFileFormat.txt ' , "FOO \n" );
171+ $ this ->module ->assertStringMatchesFormatFile ($ dir . '/expectedFileFormat.txt ' , "FOO \n" );
170172 $ this ->module ->assertStringNotContainsString ('baz ' , 'foobar ' );
171173 $ this ->module ->assertStringNotContainsStringIgnoringCase ('baz ' , 'FooBar ' );
172- $ this ->module ->assertStringNotEqualsFile (codecept_data_dir () . '/data2.txt ' , 'foo bar foo ' );
173- $ this ->module ->assertStringNotEqualsFileCanonicalizing (codecept_data_dir () . '/data3.txt ' , 'foo bar foo ' );
174- $ this ->module ->assertStringNotEqualsFileIgnoringCase (codecept_data_dir () . '/data3.txt ' , 'foo bar foo ' );
174+ $ this ->module ->assertStringNotEqualsFile ($ dir . '/data2.txt ' , 'foo bar foo ' );
175+ $ this ->module ->assertStringNotEqualsFileCanonicalizing ($ dir . '/data3.txt ' , 'foo bar foo ' );
176+ $ this ->module ->assertStringNotEqualsFileIgnoringCase ($ dir . '/data3.txt ' , 'foo bar foo ' );
175177 $ this ->module ->assertStringNotMatchesFormat ('*%s* ' , '** ' );
176- $ this ->module ->assertStringNotMatchesFormatFile (codecept_data_dir () . '/expectedFileFormat.txt ' , "FO " );
178+ $ this ->module ->assertStringNotMatchesFormatFile ($ dir . '/expectedFileFormat.txt ' , "FO " );
177179 $ this ->module ->assertStringStartsNotWith ('ba ' , 'foo ' );
178180 $ this ->module ->assertStringStartsWith ('fo ' , 'foo ' );
179181 $ this ->module ->assertThat (4 , new IsEqual (4 ));
180182 $ this ->module ->assertTrue (true );
181- $ this ->module ->assertXmlFileEqualsXmlFile (codecept_data_dir () . '/data1.xml ' , codecept_data_dir () . '/data1.xml ' );
182- $ this ->module ->assertXmlFileNotEqualsXmlFile (codecept_data_dir () . '/data1.xml ' , codecept_data_dir () . '/data2.xml ' );
183- $ this ->module ->assertXmlStringEqualsXmlFile (codecept_data_dir () . '/data1.xml ' , ' <foo>foo</foo> ' );
183+ $ this ->module ->assertXmlFileEqualsXmlFile ($ dir . '/data1.xml ' , $ dir . '/data1.xml ' );
184+ $ this ->module ->assertXmlFileNotEqualsXmlFile ($ dir . '/data1.xml ' , $ dir . '/data2.xml ' );
185+ $ this ->module ->assertXmlStringEqualsXmlFile ($ dir . '/data1.xml ' , ' <foo>foo</foo> ' );
184186 $ this ->module ->assertXmlStringEqualsXmlString ('<foo>foo</foo> ' , ' <foo>foo</foo> ' );
185- $ this ->module ->assertXmlStringNotEqualsXmlFile (codecept_data_dir () . '/data1.xml ' , '<foo>bar</foo> ' );
187+ $ this ->module ->assertXmlStringNotEqualsXmlFile ($ dir . '/data1.xml ' , '<foo>bar</foo> ' );
186188 $ this ->module ->assertXmlStringNotEqualsXmlString ('<foo>foo</foo> ' , '<foo>bar</foo> ' );
187189 }
188190
0 commit comments