Test_Import::test_import_recipe()


Source

File: tests/test-import.php

	public function test_import_recipe() {
		$path = dirname( __FILE__ ) . '/recipes/2-triggers-2-actions.json';
		$recipe_id = $this->importer->import_from_file( $path );
		//$recipe_id = $this->importer->import_from_array( $recipe );

		// Check that the recipe was added
		$this->assertSame( $recipe_id, post_exists( "Creates a post when any page is viewed" ) );

		$recipes_data = Automator()->get_recipes_data( true, $recipe_id );

		$recipe_data = array_shift( $recipes_data );

		$this->assertSame( $recipe_data['post_status'], 'publish' );

		$this->assertSame( $recipe_data['triggers'][0]['meta']['code'], 'VIEWPAGE' );
		$this->assertSame( $recipe_data['triggers'][0]['post_status'], 'publish' );
		$this->assertSame( $recipe_data['triggers'][0]['meta']['WPPAGE'], '-1' );

		$this->assertSame( $recipe_data['triggers'][1]['meta']['code'], 'VIEWPOST' );
		$this->assertSame( $recipe_data['triggers'][1]['post_status'], 'publish' );
		$this->assertSame( $recipe_data['triggers'][1]['meta']['WPPOST'], '-1' );

		$this->assertSame( $recipe_data['actions'][0]['meta']['code'], 'CREATEPOST' );
		$this->assertSame( $recipe_data['actions'][0]['post_status'], 'publish' );
		$this->assertSame( $recipe_data['actions'][0]['meta']['WPCPOSTAUTHOR'], '{{admin_email}}' );
		$this->assertSame( $recipe_data['actions'][0]['meta']['WPCPOSTTITLE'], 'A page was visited at {{current_date}} {{current_time}}' );
		$this->assertSame( $recipe_data['actions'][0]['meta']['WPCPOSTCONTENT'], 'Test content here {{' . $recipe_data['triggers'][0]['ID'] . ':VIEWPOST:WPPOST_THUMB_URL}}' );
		$this->assertSame( $recipe_data['actions'][0]['meta']['CPMETA_PAIRS'], '[{"KEY":"xx_custom_key","VALUE":"xx_custom_value"},{"KEY":"zz_custom_key","VALUE":"zz_custom_value"}]' );


		$this->assertSame( $recipe_data['actions'][1]['meta']['code'], 'SENDEMAIL' );
		$this->assertSame( $recipe_data['actions'][1]['post_status'], 'publish' );
		$this->assertSame( $recipe_data['actions'][1]['meta']['EMAILFROM'], '{{admin_email}}' );
		$this->assertSame( $recipe_data['actions'][1]['meta']['EMAILFROMNAME'], 'PHPUnit' );
		$this->assertSame( $recipe_data['actions'][1]['meta']['EMAILTO'], '{{admin_email}}' );

	}